Add the OpenFOAM source tree
This commit is contained in:
@ -0,0 +1,5 @@
|
||||
writeFluentScalarField.C
|
||||
writeFluentVectorField.C
|
||||
foamDataToFluent.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/foamDataToFluent
|
||||
@ -0,0 +1,6 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lgenericPatchFields
|
||||
@ -0,0 +1,297 @@
|
||||
enum {
|
||||
XF_RF_DATA_NULL=0,
|
||||
XF_RF_DATA_NULL_M1=0,
|
||||
XF_RF_DATA_NULL_M2=0,
|
||||
XF_RF_DATA_NULL_MEAN=0,
|
||||
XF_RF_DATA_NULL_RMS=0,
|
||||
XF_RF_DATA_PRESSURE=1,
|
||||
XF_RF_DATA_MOMENTUM=2,
|
||||
XF_RF_DATA_TEMPERATURE=3,
|
||||
XF_RF_DATA_ENTHALPY=4,
|
||||
XF_RF_DATA_TKE=5,
|
||||
XF_RF_DATA_TED=6,
|
||||
XF_RF_DATA_SPECIES=7,
|
||||
XF_RF_DATA_G=8,
|
||||
XF_RF_DATA_G_M1=0, /* never stored but symbol is required */
|
||||
XF_RF_DATA_G_M2=0,
|
||||
XF_RF_DATA_WSWIRL=9,
|
||||
XF_RF_DATA_DPMS_MASS=10,
|
||||
XF_RF_DATA_DPMS_MOM=11,
|
||||
XF_RF_DATA_DPMS_ENERGY=12,
|
||||
XF_RF_DATA_DPMS_SPECIES=13,
|
||||
XF_RF_DATA_DVOLUME_DT=14,
|
||||
XF_RF_DATA_BODY_FORCES=15,
|
||||
XF_RF_DATA_FMEAN=16,
|
||||
XF_RF_DATA_FVAR=17,
|
||||
XF_RF_DATA_MASS_FLUX=18,
|
||||
XF_RF_DATA_WALL_SHEAR=19,
|
||||
XF_RF_DATA_BOUNDARY_HEAT_FLUX=20,
|
||||
XF_RF_DATA_BOUNDARY_RAD_HEAT_FLUX=21,
|
||||
XF_RF_DATA_OLD_PRESSURE=22,
|
||||
XF_RF_DATA_POLLUT=23,
|
||||
XF_RF_DATA_DPMS_P1_S=24,
|
||||
XF_RF_DATA_DPMS_P1_AP=25,
|
||||
XF_RF_DATA_WALL_GAS_TEMPERATURE=26,
|
||||
XF_RF_DATA_DPMS_P1_DIFF=27,
|
||||
XF_RF_DATA_DR_SURF=28,
|
||||
|
||||
/* conserved variables at n-1 and n-2 time levels (rampant) */
|
||||
XF_RF_DATA_W_M1=29,
|
||||
XF_RF_DATA_W_M2=30,
|
||||
|
||||
XF_RF_DATA_DPMS_BURNOUT=31,
|
||||
XF_RF_DATA_DPMS_CONCENTRATION=32,
|
||||
XF_RF_DATA_PDF_MW=33,
|
||||
XF_RF_DATA_DPMS_WSWIRL=34,
|
||||
XF_RF_DATA_YPLUS=35,
|
||||
XF_RF_DATA_YPLUS_UTAU=36,
|
||||
XF_RF_DATA_WALL_SHEAR_SWIRL=37,
|
||||
|
||||
XF_RF_DATA_WALL_T_INNER=38,
|
||||
XF_RF_DATA_POLLUT0=39,
|
||||
XF_RF_DATA_POLLUT1=40,
|
||||
XF_RF_DATA_WALL_G_INNER=41,
|
||||
XF_RF_DATA_PREMIXC=42,
|
||||
XF_RF_DATA_PREMIXC_T=43,
|
||||
XF_RF_DATA_PREMIXC_RATE=44,
|
||||
XF_RF_DATA_POLLUT2=45,
|
||||
XF_RF_DATA_POLLUT3=46,
|
||||
|
||||
XF_RF_DATA_MASS_FLUX_M1=47,
|
||||
XF_RF_DATA_MASS_FLUX_M2=48,
|
||||
XF_RF_DATA_GRID_FLUX=49,
|
||||
|
||||
XF_RF_DATA_DO_I=50,
|
||||
XF_RF_DATA_DO_RECON_I=51,
|
||||
XF_RF_DATA_DO_ENERGY_SOURCE=52,
|
||||
XF_RF_DATA_DO_IRRAD=53,
|
||||
XF_RF_DATA_DO_QMINUS=54,
|
||||
XF_RF_DATA_DO_IRRAD_OLD=55,
|
||||
XF_RF_DATA_DO_IWX=56,
|
||||
XF_RF_DATA_DO_IWY=57,
|
||||
XF_RF_DATA_DO_IWZ=58,
|
||||
|
||||
XF_RF_DATA_MACH=59,
|
||||
|
||||
XF_RF_DATA_SLIP_U=60,
|
||||
XF_RF_DATA_SLIP_V=61,
|
||||
XF_RF_DATA_SLIP_W=62,
|
||||
|
||||
XF_RF_DATA_SDR=63, /* omega in the k-w model */
|
||||
XF_RF_DATA_SDR_M1=64,
|
||||
XF_RF_DATA_SDR_M2=65,
|
||||
|
||||
XF_RF_DATA_POLLUT4=66,
|
||||
XF_RF_DATA_GRANULAR_TEMPERATURE = 67,
|
||||
XF_RF_DATA_GRANULAR_TEMPERATURE_M1 = 68,
|
||||
XF_RF_DATA_GRANULAR_TEMPERATURE_M2 = 69,
|
||||
|
||||
XF_RF_DATA_VFLUX=70,
|
||||
|
||||
XF_RF_DATA_VFLUX_M1=80,
|
||||
|
||||
XF_RF_DATA_VFLUX_M2=90,
|
||||
|
||||
XF_RF_DATA_DO_QTRANS=92,
|
||||
XF_RF_DATA_DO_QREFL=93,
|
||||
XF_RF_DATA_DO_QABS=94,
|
||||
|
||||
XF_RF_DATA_DENSITY=101,
|
||||
XF_RF_DATA_MU_LAM=102,
|
||||
XF_RF_DATA_MU_TURB=103,
|
||||
XF_RF_DATA_CP=104,
|
||||
XF_RF_DATA_KTC=105,
|
||||
XF_RF_DATA_VGS_DTRM=106,
|
||||
XF_RF_DATA_VGF_DTRM=107,
|
||||
XF_RF_DATA_RSTRESS=108, /* V4 reynolds stress model */
|
||||
XF_RF_DATA_THREAD_RAD_FLUX=109,
|
||||
|
||||
/* mass absorption term for absorbing porous media model */
|
||||
XF_RF_DATA_SPE_Q=110,
|
||||
|
||||
XF_RF_DATA_X_VELOCITY=111,
|
||||
XF_RF_DATA_Y_VELOCITY=112,
|
||||
XF_RF_DATA_Z_VELOCITY=113,
|
||||
XF_RF_DATA_WALL_VELOCITY=114,
|
||||
|
||||
XF_RF_DATA_PRESSURE_M1=0, /* never stored but symbol is required */
|
||||
XF_RF_DATA_X_VELOCITY_M1=115,
|
||||
XF_RF_DATA_Y_VELOCITY_M1=116,
|
||||
XF_RF_DATA_Z_VELOCITY_M1=117,
|
||||
|
||||
XF_RF_DATA_PHASE_MASS=118, /* cavitation mass source */
|
||||
XF_RF_DATA_TEMPERATURE_M1=0, /* never stored but symbol is required
|
||||
*/
|
||||
XF_RF_DATA_TKE_M1=119,
|
||||
XF_RF_DATA_TED_M1=120,
|
||||
|
||||
XF_RF_DATA_PRESSURE_M2=0, /* never stored but symbol is required */
|
||||
XF_RF_DATA_X_VELOCITY_M2=122,
|
||||
XF_RF_DATA_Y_VELOCITY_M2=123,
|
||||
XF_RF_DATA_Z_VELOCITY_M2=124,
|
||||
XF_RF_DATA_TEMPERATURE_M2=0, /* never stored but symbol is required */
|
||||
XF_RF_DATA_TKE_M2=126,
|
||||
XF_RF_DATA_TED_M2=127,
|
||||
|
||||
XF_RF_DATA_RUU=128, /* V5 reynolds stress model */
|
||||
XF_RF_DATA_RVV=129, /* V5 reynolds stress model */
|
||||
XF_RF_DATA_RWW=130, /* V5 reynolds stress model */
|
||||
XF_RF_DATA_RUV=131, /* V5 reynolds stress model */
|
||||
XF_RF_DATA_RVW=132, /* V5 reynolds stress model */
|
||||
XF_RF_DATA_RUW=133, /* V5 reynolds stress model */
|
||||
|
||||
XF_RF_DATA_DPMS_EROSION=134,
|
||||
XF_RF_DATA_DPMS_ACCRETION=135,
|
||||
|
||||
XF_RF_DATA_FMEAN2=136,
|
||||
XF_RF_DATA_FVAR2=137,
|
||||
|
||||
XF_RF_DATA_ENTHALPY_M1=138,
|
||||
XF_RF_DATA_ENTHALPY_M2=139,
|
||||
|
||||
XF_RF_DATA_FMEAN_M1=140,
|
||||
XF_RF_DATA_FMEAN_M2=141,
|
||||
XF_RF_DATA_FVAR_M1=142,
|
||||
XF_RF_DATA_FVAR_M2=143,
|
||||
XF_RF_DATA_FMEAN2_M1=144,
|
||||
XF_RF_DATA_FMEAN2_M2=145,
|
||||
XF_RF_DATA_FVAR2_M1=146,
|
||||
XF_RF_DATA_FVAR2_M2=147,
|
||||
|
||||
XF_RF_DATA_PREMIXC_M1=148,
|
||||
XF_RF_DATA_PREMIXC_M2=149,
|
||||
|
||||
/*vof 1,2,3,4 kept for v5 compatibility */
|
||||
XF_RF_DATA_VOF = 150,
|
||||
XF_RF_DATA_VOF_1 = 151,
|
||||
XF_RF_DATA_VOF_2 = 152,
|
||||
XF_RF_DATA_VOF_3 = 153,
|
||||
XF_RF_DATA_VOF_4 = 154,
|
||||
|
||||
XF_RF_DATA_VOF_M1 = 160 ,
|
||||
XF_RF_DATA_VOF_1_M1 = 161 ,
|
||||
XF_RF_DATA_VOF_2_M1 = 162 ,
|
||||
XF_RF_DATA_VOF_3_M1 = 163 ,
|
||||
XF_RF_DATA_VOF_4_M1 = 164 ,
|
||||
|
||||
XF_RF_DATA_VOF_M2 = 170 ,
|
||||
XF_RF_DATA_VOF_1_M2 = 171 ,
|
||||
XF_RF_DATA_VOF_2_M2 = 172 ,
|
||||
XF_RF_DATA_VOF_3_M2 = 173 ,
|
||||
XF_RF_DATA_VOF_4_M2 = 174 ,
|
||||
|
||||
/* dynamic mesh */
|
||||
XF_RF_DATA_VOLUME_M2 = 180 ,
|
||||
XF_RF_DATA_WALL_GRID_VELOCITY = 181 ,
|
||||
|
||||
|
||||
XF_RF_DATA_SV_T_AUX = 190 , /* auxilliary temperature
|
||||
for particles */
|
||||
XF_RF_DATA_SV_T_AP_AUX = 191 , /* auxilliary ap
|
||||
coefficient for particles */
|
||||
XF_RF_DATA_TOTAL_PRESSURE=192,
|
||||
XF_RF_DATA_TOTAL_TEMPERATURE=193,
|
||||
XF_RF_DATA_NRBC_DC=194, /* change in char. var for
|
||||
nrbc*/
|
||||
|
||||
|
||||
EXPAND_50_EQUAL(XF_RF_DATA_Y_, 200), /* species */
|
||||
EXPAND_50(XF_RF_DATA_Y_,_M1=, 250), /* species at fist time
|
||||
level */
|
||||
EXPAND_50(XF_RF_DATA_Y_,_M2=, 300), /* species at second time
|
||||
level */
|
||||
EXPAND_50_EQUAL(XF_RF_DATA_DR_SURF_, 350), /* surface deposition rate
|
||||
*/
|
||||
|
||||
/* Please start next XF_RF_DATA_ subsection ids at 400 or above
|
||||
* to allow room for the addition of more species ids if needed */
|
||||
|
||||
XF_RF_DATA_PRESSURE_MEAN=400,
|
||||
XF_RF_DATA_PRESSURE_RMS=401,
|
||||
XF_RF_DATA_X_VELOCITY_MEAN=402,
|
||||
XF_RF_DATA_X_VELOCITY_RMS=403,
|
||||
XF_RF_DATA_Y_VELOCITY_MEAN=404,
|
||||
XF_RF_DATA_Y_VELOCITY_RMS=405,
|
||||
XF_RF_DATA_Z_VELOCITY_MEAN=406,
|
||||
XF_RF_DATA_Z_VELOCITY_RMS=407,
|
||||
XF_RF_DATA_TEMPERATURE_MEAN=408,
|
||||
XF_RF_DATA_TEMPERATURE_RMS=409,
|
||||
XF_RF_DATA_VOF_MEAN=410,
|
||||
XF_RF_DATA_VOF_RMS=411,
|
||||
EXPAND_50_EQUAL(XF_RF_DATA_DPMS_Y_,450),
|
||||
|
||||
/* Don't add section ids here unless you need a large contiguous
|
||||
chunk.
|
||||
* Use id's 40-100 first! */
|
||||
XF_RF_DATA_NUT=500,
|
||||
XF_RF_DATA_NUT_M1=501,
|
||||
XF_RF_DATA_NUT_M2=502,
|
||||
|
||||
XF_RF_DATA_RUU_M1=503,
|
||||
XF_RF_DATA_RVV_M1=504,
|
||||
XF_RF_DATA_RWW_M1=505,
|
||||
XF_RF_DATA_RUV_M1=506,
|
||||
XF_RF_DATA_RVW_M1=507,
|
||||
XF_RF_DATA_RUW_M1=508,
|
||||
|
||||
XF_RF_DATA_RUU_M2=509,
|
||||
XF_RF_DATA_RVV_M2=510,
|
||||
XF_RF_DATA_RWW_M2=511,
|
||||
XF_RF_DATA_RUV_M2=512,
|
||||
XF_RF_DATA_RVW_M2=513,
|
||||
XF_RF_DATA_RUW_M2=514,
|
||||
|
||||
XF_RF_DATA_ENERGY_M1=515,
|
||||
XF_RF_DATA_ENERGY_M2=516,
|
||||
|
||||
XF_RF_DATA_DENSITY_M1=517,
|
||||
XF_RF_DATA_DENSITY_M2=518,
|
||||
|
||||
XF_RF_DATA_DPMS_PDF_1=519,
|
||||
XF_RF_DATA_DPMS_PDF_2=520,
|
||||
|
||||
/* shell: using 530->539 */
|
||||
XF_RF_DATA_SHELL_CELL_T=530,
|
||||
XF_RF_DATA_SHELL_FACE_T=531,
|
||||
|
||||
XF_RF_DATA_DELH=600, /* obsolete for >= v6.0*/
|
||||
XF_RF_DATA_DPMS_MOM_AP=601,
|
||||
XF_RF_DATA_DPMS_WSWIRL_AP=602,
|
||||
XF_RF_DATA_X_PULL=603,
|
||||
XF_RF_DATA_Y_PULL=604,
|
||||
XF_RF_DATA_Z_PULL=605,
|
||||
XF_RF_DATA_LIQF=606,
|
||||
|
||||
/* pdf transport */
|
||||
XF_RF_DATA_PDFT_QBAR=610,
|
||||
XF_RF_DATA_PDFT_PHI=611,
|
||||
XF_RF_DATA_PDFT_Q_TA=612,
|
||||
XF_RF_DATA_PDFT_SVOL_TA=613,
|
||||
XF_RF_DATA_PDFT_MASS_TA=614,
|
||||
|
||||
EXPAND_50_EQUAL(XF_RF_DATA_UDS_,700), /* user defined scalar */
|
||||
EXPAND_50(XF_RF_DATA_UDS_,_M1=, 750), /* user defined scalar
|
||||
* at fist time level */
|
||||
EXPAND_50(XF_RF_DATA_UDS_,_M2=, 800), /* user defined scalar
|
||||
* at second time level */
|
||||
XF_RF_DATA_GRANULAR_PRESSURE=910,
|
||||
XF_RF_DATA_GRANULAR_PRESSURE_M1=0,/* never stored but symbol is
|
||||
required */
|
||||
XF_RF_DATA_GRANULAR_PRESSURE_M2=0,/* never stored but symbol is
|
||||
required */
|
||||
|
||||
XF_RF_DATA_UDM_I=970,
|
||||
|
||||
/* Don't add section ids here unless you need a large contiguous
|
||||
chunk.
|
||||
* Use id's 40-100 and 128-200 first! */
|
||||
|
||||
|
||||
EXPAND_50(XF_RF_DATA_Y_,_MEAN=, 1000), /* time average species */
|
||||
EXPAND_50(XF_RF_DATA_Y_,_RMS=, 1050), /* RMS species */
|
||||
|
||||
EXPAND_50_EQUAL(XF_RF_DATA_Y_EDC_, 1100), /* EDC species */
|
||||
EXPAND_50_EQUAL(XF_RF_DATA_DPMS_SURFACE_SPECIES_, 1150) /* particle
|
||||
surface species */
|
||||
|
||||
};
|
||||
@ -0,0 +1,167 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Application
|
||||
foamDataToFluent
|
||||
|
||||
Description
|
||||
Translates OpenFOAM data to Fluent format.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "writeFluentFields.H"
|
||||
#include "OFstream.H"
|
||||
#include "IOobjectList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
timeSelector::addOptions(false); // no constant
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
|
||||
# include "createMesh.H"
|
||||
|
||||
// make a directory called proInterface in the case
|
||||
mkDir(runTime.rootPath()/runTime.caseName()/"fluentInterface");
|
||||
|
||||
forAll(timeDirs, timeI)
|
||||
{
|
||||
runTime.setTime(timeDirs[timeI], timeI);
|
||||
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
if (mesh.readUpdate())
|
||||
{
|
||||
Info<< " Read new mesh" << endl;
|
||||
}
|
||||
|
||||
// make a directory called proInterface in the case
|
||||
mkDir(runTime.rootPath()/runTime.caseName()/"fluentInterface");
|
||||
|
||||
// open a file for the mesh
|
||||
OFstream fluentDataFile
|
||||
(
|
||||
runTime.rootPath()/
|
||||
runTime.caseName()/
|
||||
"fluentInterface"/
|
||||
runTime.caseName() + runTime.timeName() + ".dat"
|
||||
);
|
||||
|
||||
fluentDataFile
|
||||
<< "(0 \"FOAM to Fluent data File\")" << endl << endl;
|
||||
|
||||
// Writing number of faces
|
||||
label nFaces = mesh.nFaces();
|
||||
|
||||
forAll(mesh.boundary(), patchI)
|
||||
{
|
||||
nFaces += mesh.boundary()[patchI].size();
|
||||
}
|
||||
|
||||
fluentDataFile
|
||||
<< "(33 (" << mesh.nCells() << " " << nFaces << " "
|
||||
<< mesh.nPoints() << "))" << endl;
|
||||
|
||||
IOdictionary foamDataToFluentDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"foamDataToFluentDict",
|
||||
runTime.system(),
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Search for list of objects for this time
|
||||
IOobjectList objects(mesh, runTime.timeName());
|
||||
|
||||
|
||||
// Converting volScalarField
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// Search list of objects for volScalarFields
|
||||
IOobjectList scalarFields(objects.lookupClass("volScalarField"));
|
||||
|
||||
forAllIter(IOobjectList, scalarFields, iter)
|
||||
{
|
||||
// Read field
|
||||
volScalarField field(*iter(), mesh);
|
||||
|
||||
// lookup field from dictionary and convert field
|
||||
label unitNumber;
|
||||
if
|
||||
(
|
||||
foamDataToFluentDict.readIfPresent(field.name(), unitNumber)
|
||||
&& unitNumber > 0
|
||||
)
|
||||
{
|
||||
Info<< " Converting field " << field.name() << endl;
|
||||
writeFluentField(field, unitNumber, fluentDataFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Converting volVectorField
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// Search list of objects for volVectorFields
|
||||
IOobjectList vectorFields(objects.lookupClass("volVectorField"));
|
||||
|
||||
forAllIter(IOobjectList, vectorFields, iter)
|
||||
{
|
||||
// Read field
|
||||
volVectorField field(*iter(), mesh);
|
||||
|
||||
// lookup field from dictionary and convert field
|
||||
label unitNumber;
|
||||
if
|
||||
(
|
||||
foamDataToFluentDict.readIfPresent(field.name(), unitNumber)
|
||||
&& unitNumber > 0
|
||||
)
|
||||
{
|
||||
Info<< " Converting field " << field.name() << endl;
|
||||
writeFluentField(field, unitNumber, fluentDataFile);
|
||||
}
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,21 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: dev |
|
||||
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
note "OpenFOAM to Fluent interface control dictionary";
|
||||
class dictionary;
|
||||
object foamDataToFluentDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
p 1;
|
||||
U 2;
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,62 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InClass
|
||||
Foam::writeFluentFields
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writeFluentFields_H
|
||||
#define writeFluentFields_H
|
||||
|
||||
#include "volFields.H"
|
||||
#include "Ostream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
void writeFluentField
|
||||
(
|
||||
const volScalarField& phi,
|
||||
const label fluentFieldIdentifier,
|
||||
Ostream& stream
|
||||
);
|
||||
|
||||
void writeFluentField
|
||||
(
|
||||
const volVectorField& phi,
|
||||
const label fluentFieldIdentifier,
|
||||
Ostream& stream
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,141 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Description
|
||||
Given a volScalarField and Fluent field identifier, write the field in
|
||||
Fluent data format
|
||||
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "writeFluentFields.H"
|
||||
#include "emptyFvPatchFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void writeFluentField
|
||||
(
|
||||
const volScalarField& phi,
|
||||
const label fluentFieldIdentifier,
|
||||
Ostream& stream
|
||||
)
|
||||
{
|
||||
const scalarField& phiInternal = phi.internalField();
|
||||
|
||||
// Writing cells
|
||||
stream
|
||||
<< "(300 ("
|
||||
<< fluentFieldIdentifier << " " // Field identifier
|
||||
<< "1 " // Zone ID: (cells=1, internal faces=2,
|
||||
// patch faces=patchI+10)
|
||||
<< "1 " // Number of components (scalar=1, vector=3)
|
||||
<< "0 0 " // Unused
|
||||
<< "1 " << phiInternal.size() // Start and end of list
|
||||
<< ")(" << endl;
|
||||
|
||||
forAll(phiInternal, cellI)
|
||||
{
|
||||
stream << phiInternal[cellI] << endl;
|
||||
}
|
||||
|
||||
stream
|
||||
<< "))" << endl;
|
||||
|
||||
label nWrittenFaces = phiInternal.size();
|
||||
|
||||
// Writing boundary faces
|
||||
forAll(phi.boundaryField(), patchI)
|
||||
{
|
||||
if (isType<emptyFvPatchScalarField>(phi.boundaryField()[patchI]))
|
||||
{
|
||||
// Form empty patch field repeat the internal field to
|
||||
// allow for the node interpolation in Fluent
|
||||
const scalarField& phiInternal = phi.internalField();
|
||||
|
||||
// Get reference to internal cells
|
||||
const labelList emptyFaceCells =
|
||||
phi.boundaryField()[patchI].patch().patch().faceCells();
|
||||
|
||||
// Writing cells for empty patch
|
||||
stream
|
||||
<< "(300 ("
|
||||
<< fluentFieldIdentifier << " " // Field identifier
|
||||
<< patchI + 10 << " " // Zone ID: patchI+10
|
||||
<< "1 " // Number of components (scalar=1, vector=3)
|
||||
<< "0 0 " // Unused
|
||||
<< nWrittenFaces + 1 << " "
|
||||
<< nWrittenFaces + emptyFaceCells.size()// Start and end of list
|
||||
<< ")(" << endl;
|
||||
|
||||
nWrittenFaces += emptyFaceCells.size();
|
||||
|
||||
forAll(emptyFaceCells, faceI)
|
||||
{
|
||||
stream << phiInternal[emptyFaceCells[faceI]] << endl;
|
||||
}
|
||||
|
||||
stream
|
||||
<< "))" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Regular patch
|
||||
label nWrittenFaces = phiInternal.size();
|
||||
|
||||
const scalarField& patchPhi = phi.boundaryField()[patchI];
|
||||
|
||||
// Write header
|
||||
stream
|
||||
<< "(300 ("
|
||||
<< fluentFieldIdentifier << " " // Field identifier
|
||||
<< patchI + 10 << " " // Zone ID: patchI+10
|
||||
<< "1 " // Number of components (scalar=1, vector=3)
|
||||
<< "0 0 " // Unused
|
||||
<< nWrittenFaces + 1 << " " << nWrittenFaces + patchPhi.size()
|
||||
// Start and end of list
|
||||
<< ")(" << endl;
|
||||
|
||||
nWrittenFaces += patchPhi.size();
|
||||
|
||||
forAll(patchPhi, faceI)
|
||||
{
|
||||
stream << patchPhi[faceI] << endl;
|
||||
}
|
||||
|
||||
stream
|
||||
<< "))" << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,109 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Description
|
||||
Given a volVectorField and Fluent field identifier, write the field in
|
||||
Fluent data format
|
||||
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "writeFluentFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void writeFluentField
|
||||
(
|
||||
const volVectorField& phi,
|
||||
const label fluentFieldIdentifier,
|
||||
Ostream& stream
|
||||
)
|
||||
{
|
||||
const vectorField& phiInternal = phi.internalField();
|
||||
|
||||
// Writing cells
|
||||
stream
|
||||
<< "(300 ("
|
||||
<< fluentFieldIdentifier << " " // Field identifier
|
||||
<< "1 " // Zone ID: (cells=1, internal faces=2,
|
||||
// patch faces=patchI+10)
|
||||
<< "3 " // Number of components (scalar=1, vector=3)
|
||||
<< "0 0 " // Unused
|
||||
<< "1 " << phiInternal.size() // Start and end of list
|
||||
<< ")(" << endl;
|
||||
|
||||
forAll(phiInternal, cellI)
|
||||
{
|
||||
stream
|
||||
<< phiInternal[cellI].x() << " "
|
||||
<< phiInternal[cellI].y() << " "
|
||||
<< phiInternal[cellI].z() << " "
|
||||
<< endl;
|
||||
}
|
||||
|
||||
stream
|
||||
<< "))" << endl;
|
||||
|
||||
label nWrittenFaces = phiInternal.size();
|
||||
|
||||
// Writing boundary faces
|
||||
forAll(phi.boundaryField(), patchI)
|
||||
{
|
||||
const vectorField& patchPhi = phi.boundaryField()[patchI];
|
||||
|
||||
// Write header
|
||||
stream
|
||||
<< "(300 ("
|
||||
<< fluentFieldIdentifier << " " // Field identifier
|
||||
<< patchI + 10 << " " // Zone ID: patchI+10
|
||||
<< "3 " // Number of components (scalar=1, vector=3)
|
||||
<< "0 0 " // Unused
|
||||
<< nWrittenFaces + 1 << " " << nWrittenFaces + patchPhi.size()
|
||||
// Start and end of list
|
||||
<< ")(" << endl;
|
||||
|
||||
nWrittenFaces += patchPhi.size();
|
||||
|
||||
forAll(patchPhi, faceI)
|
||||
{
|
||||
stream
|
||||
<< patchPhi[faceI].x() << " "
|
||||
<< patchPhi[faceI].y() << " "
|
||||
<< patchPhi[faceI].z() << " "
|
||||
<< endl;
|
||||
}
|
||||
|
||||
stream
|
||||
<< "))" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,6 @@
|
||||
itoa.C
|
||||
ensightMesh.C
|
||||
ensightParticlePositions.C
|
||||
foamToEnsight.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/foamToEnsight
|
||||
@ -0,0 +1,14 @@
|
||||
EXE_INC = \
|
||||
/* -DFULLDEBUG -g -O0 */ \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools \
|
||||
-lsampling \
|
||||
-lgenericPatchFields \
|
||||
-llagrangian
|
||||
|
||||
@ -0,0 +1,112 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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::cellSets
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef cellSets_H
|
||||
#define cellSets_H
|
||||
|
||||
#include "labelList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cellSets Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cellSets
|
||||
{
|
||||
public:
|
||||
|
||||
label nTets;
|
||||
label nPyrs;
|
||||
label nPrisms;
|
||||
label nHexesWedges;
|
||||
label nPolys;
|
||||
|
||||
labelList tets;
|
||||
labelList pyrs;
|
||||
labelList prisms;
|
||||
labelList wedges;
|
||||
labelList hexes;
|
||||
labelList polys;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given the number ov cells
|
||||
cellSets(const label nCells)
|
||||
:
|
||||
nTets(0),
|
||||
nPyrs(0),
|
||||
nPrisms(0),
|
||||
nHexesWedges(0),
|
||||
nPolys(0),
|
||||
|
||||
tets(nCells),
|
||||
pyrs(nCells),
|
||||
prisms(nCells),
|
||||
wedges(nCells),
|
||||
hexes(nCells),
|
||||
polys(nCells)
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
void setSize(const label nCells)
|
||||
{
|
||||
nTets = 0;
|
||||
nPyrs = 0;
|
||||
nPrisms = 0;
|
||||
nHexesWedges = 0;
|
||||
nPolys = 0;
|
||||
|
||||
tets.setSize(nCells);
|
||||
pyrs.setSize(nCells);
|
||||
prisms.setSize(nCells);
|
||||
wedges.setSize(nCells);
|
||||
hexes.setSize(nCells);
|
||||
polys.setSize(nCells);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,21 @@
|
||||
// ignore special fields or fields that we don't handle
|
||||
//
|
||||
bool variableGood = true;
|
||||
for (label n1=0; n1<Times.size() && variableGood; ++n1)
|
||||
{
|
||||
// ignore _0 fields
|
||||
if (fieldName.size() > 2 && fieldName(fieldName.size() - 2, 2) == "_0")
|
||||
{
|
||||
variableGood = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
variableGood = IOobject
|
||||
(
|
||||
fieldName,
|
||||
Times[n1].name(),
|
||||
mesh,
|
||||
IOobject::NO_READ
|
||||
).headerOk();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
// check for "points" in any of the result directories
|
||||
|
||||
bool meshMoving = false;
|
||||
if (Times.size() > 1)
|
||||
{
|
||||
// We already loaded a mesh (usually from constant). See if any other
|
||||
// points files
|
||||
forAll(Times, timeI)
|
||||
{
|
||||
if (Times[timeI].name() != mesh.pointsInstance())
|
||||
{
|
||||
IOobject io
|
||||
(
|
||||
"points",
|
||||
Times[timeI].name(),
|
||||
polyMesh::meshSubDir,
|
||||
mesh,
|
||||
IOobject::NO_READ
|
||||
);
|
||||
if (io.headerOk())
|
||||
{
|
||||
meshMoving = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,161 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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::ensightAsciiStream
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
ensightAsciiStream.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ensightAsciiStream_H
|
||||
#define ensightAsciiStream_H
|
||||
|
||||
#include "ensightStream.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ensightAsciiStream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class ensightAsciiStream
|
||||
:
|
||||
public ensightStream
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Description of data_
|
||||
OFstream str_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
ensightAsciiStream(const ensightAsciiStream&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const ensightAsciiStream&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
ensightAsciiStream(const fileName& f, const Time& runTime)
|
||||
:
|
||||
ensightStream(f),
|
||||
str_
|
||||
(
|
||||
f,
|
||||
runTime.writeFormat(),
|
||||
runTime.writeVersion(),
|
||||
IOstream::UNCOMPRESSED
|
||||
)
|
||||
{
|
||||
|
||||
str_.setf(ios_base::scientific, ios_base::floatfield);
|
||||
str_.precision(5);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ensightAsciiStream()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual bool ascii() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void write(const char* c)
|
||||
{
|
||||
str_ << c << nl;
|
||||
}
|
||||
|
||||
virtual void write(const int v)
|
||||
{
|
||||
str_ << setw(10) << v << nl;
|
||||
}
|
||||
|
||||
virtual void write(const scalarField& sf)
|
||||
{
|
||||
forAll(sf, i)
|
||||
{
|
||||
if (mag(sf[i]) >= scalar(floatScalarVSMALL))
|
||||
{
|
||||
str_ << setw(12) << sf[i] << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
str_ << setw(12) << scalar(0) << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void write(const List<int>& sf)
|
||||
{
|
||||
forAll(sf, i)
|
||||
{
|
||||
str_ << setw(10) << sf[i];
|
||||
}
|
||||
str_<< nl;
|
||||
}
|
||||
|
||||
virtual void writePartHeader(const label partI)
|
||||
{
|
||||
str_<< "part" << nl
|
||||
<< setw(10) << partI << nl;
|
||||
}
|
||||
|
||||
// Member Operators
|
||||
|
||||
// Friend Functions
|
||||
|
||||
// Friend Operators
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,163 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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::ensightBinaryStream
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
ensightBinaryStream.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ensightBinaryStream_H
|
||||
#define ensightBinaryStream_H
|
||||
|
||||
#include "ensightStream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ensightBinaryStream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class ensightBinaryStream
|
||||
:
|
||||
public ensightStream
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Description of data_
|
||||
autoPtr<std::ofstream> str_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
ensightBinaryStream(const ensightBinaryStream&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const ensightBinaryStream&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
ensightBinaryStream(const fileName& f, const Time&)
|
||||
:
|
||||
ensightStream(f),
|
||||
str_
|
||||
(
|
||||
new std::ofstream
|
||||
(
|
||||
f.c_str(),
|
||||
ios_base::out | ios_base::binary | ios_base::trunc
|
||||
)
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ensightBinaryStream()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual bool ascii() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void write(const char* val)
|
||||
{
|
||||
char buffer[80] = {0};
|
||||
strcpy(buffer, val);
|
||||
str_().write(buffer, 80*sizeof(char));
|
||||
}
|
||||
|
||||
virtual void write(const int val)
|
||||
{
|
||||
str_().write(reinterpret_cast<const char*>(&val), sizeof(int));
|
||||
}
|
||||
|
||||
virtual void write(const scalarField& sf)
|
||||
{
|
||||
if (sf.size())
|
||||
{
|
||||
List<float> temp(sf.size());
|
||||
|
||||
forAll(sf, i)
|
||||
{
|
||||
temp[i] = float(sf[i]);
|
||||
}
|
||||
|
||||
str_().write
|
||||
(
|
||||
reinterpret_cast<const char*>(temp.begin()),
|
||||
sf.size()*sizeof(float)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void write(const List<int>& sf)
|
||||
{
|
||||
str_().write
|
||||
(
|
||||
reinterpret_cast<const char*>(sf.begin()),
|
||||
sf.size()*sizeof(int)
|
||||
);
|
||||
}
|
||||
|
||||
virtual void writePartHeader(const label partI)
|
||||
{
|
||||
write("part");
|
||||
write(partI);
|
||||
}
|
||||
|
||||
// Member Operators
|
||||
|
||||
// Friend Functions
|
||||
|
||||
// Friend Operators
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,33 @@
|
||||
if (Pstream::master())
|
||||
{
|
||||
ensightCaseFile << nl << "TIME" << nl
|
||||
<< "time set: " << 1 << nl
|
||||
<< "number of steps: " << nTimeSteps << nl
|
||||
<< "filename start number: " << 0 << nl
|
||||
<< "filename increment: " << 1 << nl;
|
||||
|
||||
ensightCaseFile << "time values:" << nl;
|
||||
|
||||
ensightCaseFile.setf(ios_base::scientific, ios_base::floatfield);
|
||||
ensightCaseFile.precision(5);
|
||||
|
||||
label count = 0;
|
||||
scalar Tcorr = 0.0;
|
||||
if (Times[0].value() < 0)
|
||||
{
|
||||
Tcorr = - Times[0].value();
|
||||
Info<< "Correcting time values. Adding " << Tcorr << endl;
|
||||
}
|
||||
|
||||
forAll(Times, n)
|
||||
{
|
||||
ensightCaseFile << setw(12) << Times[n].value() + Tcorr << " ";
|
||||
|
||||
if (++count % 6 == 0)
|
||||
{
|
||||
ensightCaseFile << nl;
|
||||
}
|
||||
}
|
||||
|
||||
ensightCaseFile << nl;
|
||||
}
|
||||
@ -0,0 +1,126 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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 "ensightCloudField.H"
|
||||
#include "Time.H"
|
||||
#include "IOField.H"
|
||||
#include "OFstream.H"
|
||||
#include "IOmanip.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void ensightCloudField
|
||||
(
|
||||
const IOobject& fieldObject,
|
||||
const fileName& postProcPath,
|
||||
const word& prepend,
|
||||
const label timeIndex,
|
||||
const word& cloudName,
|
||||
Ostream& ensightCaseFile,
|
||||
const bool dataExists
|
||||
)
|
||||
{
|
||||
if (dataExists)
|
||||
{
|
||||
Info<< "Converting cloud " << cloudName
|
||||
<< " field " << fieldObject.name() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Creating empty cloud " << cloudName
|
||||
<< " field " << fieldObject.name() << endl;
|
||||
}
|
||||
|
||||
word timeFile = prepend + itoa(timeIndex);
|
||||
|
||||
const Time& runTime = fieldObject.time();
|
||||
|
||||
if (timeIndex == 0 && Pstream::master())
|
||||
{
|
||||
ensightCaseFile
|
||||
<< pTraits<Type>::typeName << " per measured node: 1 ";
|
||||
ensightCaseFile.width(15);
|
||||
ensightCaseFile.setf(ios_base::left);
|
||||
ensightCaseFile
|
||||
<< ("c" + fieldObject.name()).c_str()
|
||||
<< (' ' + prepend + "****." + cloudName
|
||||
+ "." + fieldObject.name()).c_str()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
fileName ensightFileName
|
||||
(
|
||||
timeFile + "." + cloudName +"." + fieldObject.name()
|
||||
);
|
||||
|
||||
OFstream ensightFile
|
||||
(
|
||||
postProcPath/ensightFileName,
|
||||
runTime.writeFormat(),
|
||||
runTime.writeVersion(),
|
||||
runTime.writeCompression()
|
||||
);
|
||||
|
||||
ensightFile<< pTraits<Type>::typeName << " values" << nl;
|
||||
|
||||
if (dataExists)
|
||||
{
|
||||
IOField<Type> vf(fieldObject);
|
||||
|
||||
ensightFile.setf(ios_base::scientific, ios_base::floatfield);
|
||||
ensightFile.precision(5);
|
||||
|
||||
label count = 0;
|
||||
forAll(vf, i)
|
||||
{
|
||||
Type v = vf[i];
|
||||
|
||||
if (mag(v) < 1.0e-90)
|
||||
{
|
||||
v = pTraits<Type>::zero;
|
||||
}
|
||||
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
ensightFile << setw(12) << component(v, cmpt);
|
||||
if (++count % 6 == 0)
|
||||
{
|
||||
ensightFile << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((count % 6 != 0) || (count==0))
|
||||
{
|
||||
ensightFile << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,65 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InApplication
|
||||
foamToEnsight
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
ensightCloudField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ensightCloudField_H
|
||||
#define ensightCloudField_H
|
||||
|
||||
#include "Cloud.H"
|
||||
#include "IOobject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void ensightCloudField
|
||||
(
|
||||
const IOobject& fieldObject,
|
||||
const fileName& postProcPath,
|
||||
const word& prepend,
|
||||
const label timeIndex,
|
||||
const word& timeFile,
|
||||
const word& cloudName,
|
||||
Ostream& ensightCaseFile,
|
||||
const bool dataExists
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "ensightCloudField.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,761 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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 "ensightField.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "OFstream.H"
|
||||
#include "IOmanip.H"
|
||||
#include "itoa.H"
|
||||
#include "volPointInterpolation.H"
|
||||
#include "ensightBinaryStream.H"
|
||||
#include "ensightAsciiStream.H"
|
||||
#include "globalIndex.H"
|
||||
#include "ensightPTraits.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh> >
|
||||
volField
|
||||
(
|
||||
const fvMeshSubset& meshSubsetter,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vf
|
||||
)
|
||||
{
|
||||
if (meshSubsetter.hasSubMesh())
|
||||
{
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh> > tfld
|
||||
(
|
||||
meshSubsetter.interpolate(vf)
|
||||
);
|
||||
tfld().checkOut();
|
||||
tfld().rename(vf.name());
|
||||
return tfld;
|
||||
}
|
||||
else
|
||||
{
|
||||
return vf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Field<Type> map
|
||||
(
|
||||
const Field<Type>& vf,
|
||||
const labelList& map1,
|
||||
const labelList& map2
|
||||
)
|
||||
{
|
||||
Field<Type> mf(map1.size() + map2.size());
|
||||
|
||||
forAll(map1, i)
|
||||
{
|
||||
mf[i] = vf[map1[i]];
|
||||
}
|
||||
|
||||
label offset = map1.size();
|
||||
|
||||
forAll(map2, i)
|
||||
{
|
||||
mf[i + offset] = vf[map2[i]];
|
||||
}
|
||||
|
||||
return mf;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void writeField
|
||||
(
|
||||
const char* key,
|
||||
const Field<Type>& vf,
|
||||
ensightStream& ensightFile
|
||||
)
|
||||
{
|
||||
if (returnReduce(vf.size(), sumOp<label>()) > 0)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
ensightFile.write(key);
|
||||
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
ensightFile.write(vf.component(cmpt));
|
||||
|
||||
for (int slave=1; slave<Pstream::nProcs(); slave++)
|
||||
{
|
||||
IPstream fromSlave(Pstream::scheduled, slave);
|
||||
scalarField slaveData(fromSlave);
|
||||
ensightFile.write(slaveData);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||
toMaster<< vf.component(cmpt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool writePatchField
|
||||
(
|
||||
const Field<Type>& pf,
|
||||
const label patchi,
|
||||
const label ensightPatchI,
|
||||
const faceSets& boundaryFaceSet,
|
||||
const ensightMesh::nFacePrimitives& nfp,
|
||||
ensightStream& ensightFile
|
||||
)
|
||||
{
|
||||
if (nfp.nTris || nfp.nQuads || nfp.nPolys)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
ensightFile.writePartHeader(ensightPatchI);
|
||||
}
|
||||
|
||||
writeField
|
||||
(
|
||||
"tria3",
|
||||
Field<Type>(pf, boundaryFaceSet.tris),
|
||||
ensightFile
|
||||
);
|
||||
|
||||
writeField
|
||||
(
|
||||
"quad4",
|
||||
Field<Type>(pf, boundaryFaceSet.quads),
|
||||
ensightFile
|
||||
);
|
||||
|
||||
writeField
|
||||
(
|
||||
"nsided",
|
||||
Field<Type>(pf, boundaryFaceSet.polys),
|
||||
ensightFile
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void writePatchField
|
||||
(
|
||||
const word& fieldName,
|
||||
const Field<Type>& pf,
|
||||
const word& patchName,
|
||||
const ensightMesh& eMesh,
|
||||
const fileName& postProcPath,
|
||||
const word& prepend,
|
||||
const label timeIndex,
|
||||
const bool binary,
|
||||
Ostream& ensightCaseFile
|
||||
)
|
||||
{
|
||||
const Time& runTime = eMesh.mesh().time();
|
||||
|
||||
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
|
||||
const wordList& allPatchNames = eMesh.allPatchNames();
|
||||
const HashTable<ensightMesh::nFacePrimitives>&
|
||||
nPatchPrims = eMesh.nPatchPrims();
|
||||
|
||||
label ensightPatchI = eMesh.patchPartOffset();
|
||||
|
||||
label patchi = -1;
|
||||
|
||||
forAll(allPatchNames, i)
|
||||
{
|
||||
if (allPatchNames[i] == patchName)
|
||||
{
|
||||
patchi = i;
|
||||
break;
|
||||
}
|
||||
ensightPatchI++;
|
||||
}
|
||||
|
||||
|
||||
word pfName = patchName + '.' + fieldName;
|
||||
|
||||
word timeFile = prepend + itoa(timeIndex);
|
||||
|
||||
ensightStream* ensightFilePtr = NULL;
|
||||
if (Pstream::master())
|
||||
{
|
||||
if (timeIndex == 0)
|
||||
{
|
||||
ensightCaseFile.setf(ios_base::left);
|
||||
|
||||
ensightCaseFile
|
||||
<< ensightPTraits<Type>::typeName
|
||||
<< " per element: 1 "
|
||||
<< setw(15) << pfName
|
||||
<< (' ' + prepend + "****." + pfName).c_str()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
// set the filename of the ensight file
|
||||
fileName ensightFileName(timeFile + "." + pfName);
|
||||
|
||||
if (binary)
|
||||
{
|
||||
ensightFilePtr = new ensightBinaryStream
|
||||
(
|
||||
postProcPath/ensightFileName,
|
||||
runTime
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
ensightFilePtr = new ensightAsciiStream
|
||||
(
|
||||
postProcPath/ensightFileName,
|
||||
runTime
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ensightStream& ensightFile = *ensightFilePtr;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
ensightFile.write(ensightPTraits<Type>::typeName);
|
||||
}
|
||||
|
||||
if (patchi >= 0)
|
||||
{
|
||||
writePatchField
|
||||
(
|
||||
pf,
|
||||
patchi,
|
||||
ensightPatchI,
|
||||
boundaryFaceSets[patchi],
|
||||
nPatchPrims.find(patchName)(),
|
||||
ensightFile
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
faceSets nullFaceSets;
|
||||
|
||||
writePatchField
|
||||
(
|
||||
Field<Type>(),
|
||||
-1,
|
||||
ensightPatchI,
|
||||
nullFaceSets,
|
||||
nPatchPrims.find(patchName)(),
|
||||
ensightFile
|
||||
);
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
delete ensightFilePtr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void ensightField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vf,
|
||||
const ensightMesh& eMesh,
|
||||
const fileName& postProcPath,
|
||||
const word& prepend,
|
||||
const label timeIndex,
|
||||
const bool binary,
|
||||
Ostream& ensightCaseFile
|
||||
)
|
||||
{
|
||||
Info<< "Converting field " << vf.name() << endl;
|
||||
|
||||
word timeFile = prepend + itoa(timeIndex);
|
||||
|
||||
const fvMesh& mesh = eMesh.mesh();
|
||||
const Time& runTime = mesh.time();
|
||||
|
||||
const cellSets& meshCellSets = eMesh.meshCellSets();
|
||||
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
|
||||
const wordList& allPatchNames = eMesh.allPatchNames();
|
||||
const wordHashSet& patchNames = eMesh.patchNames();
|
||||
const HashTable<ensightMesh::nFacePrimitives>&
|
||||
nPatchPrims = eMesh.nPatchPrims();
|
||||
const List<faceSets>& faceZoneFaceSets = eMesh.faceZoneFaceSets();
|
||||
const wordHashSet& faceZoneNames = eMesh.faceZoneNames();
|
||||
const HashTable<ensightMesh::nFacePrimitives>&
|
||||
nFaceZonePrims = eMesh.nFaceZonePrims();
|
||||
|
||||
const labelList& tets = meshCellSets.tets;
|
||||
const labelList& pyrs = meshCellSets.pyrs;
|
||||
const labelList& prisms = meshCellSets.prisms;
|
||||
const labelList& wedges = meshCellSets.wedges;
|
||||
const labelList& hexes = meshCellSets.hexes;
|
||||
const labelList& polys = meshCellSets.polys;
|
||||
|
||||
ensightStream* ensightFilePtr = NULL;
|
||||
if (Pstream::master())
|
||||
{
|
||||
// set the filename of the ensight file
|
||||
fileName ensightFileName(timeFile + "." + vf.name());
|
||||
|
||||
if (binary)
|
||||
{
|
||||
ensightFilePtr = new ensightBinaryStream
|
||||
(
|
||||
postProcPath/ensightFileName,
|
||||
runTime
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
ensightFilePtr = new ensightAsciiStream
|
||||
(
|
||||
postProcPath/ensightFileName,
|
||||
runTime
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ensightStream& ensightFile = *ensightFilePtr;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
if (timeIndex == 0)
|
||||
{
|
||||
ensightCaseFile.setf(ios_base::left);
|
||||
|
||||
ensightCaseFile
|
||||
<< ensightPTraits<Type>::typeName
|
||||
<< " per element: 1 "
|
||||
<< setw(15) << vf.name()
|
||||
<< (' ' + prepend + "****." + vf.name()).c_str()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
ensightFile.write(ensightPTraits<Type>::typeName);
|
||||
}
|
||||
|
||||
if (patchNames.empty())
|
||||
{
|
||||
eMesh.barrier();
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
ensightFile.writePartHeader(1);
|
||||
}
|
||||
|
||||
writeField
|
||||
(
|
||||
"hexa8",
|
||||
map(vf, hexes, wedges),
|
||||
ensightFile
|
||||
);
|
||||
|
||||
writeField
|
||||
(
|
||||
"penta6",
|
||||
Field<Type>(vf, prisms),
|
||||
ensightFile
|
||||
);
|
||||
|
||||
writeField
|
||||
(
|
||||
"pyramid5",
|
||||
Field<Type>(vf, pyrs),
|
||||
ensightFile
|
||||
);
|
||||
|
||||
writeField
|
||||
(
|
||||
"tetra4",
|
||||
Field<Type>(vf, tets),
|
||||
ensightFile
|
||||
);
|
||||
|
||||
writeField
|
||||
(
|
||||
"nfaced",
|
||||
Field<Type>(vf, polys),
|
||||
ensightFile
|
||||
);
|
||||
}
|
||||
|
||||
label ensightPatchI = eMesh.patchPartOffset();
|
||||
|
||||
forAll(allPatchNames, patchi)
|
||||
{
|
||||
const word& patchName = allPatchNames[patchi];
|
||||
|
||||
eMesh.barrier();
|
||||
|
||||
if (patchNames.empty() || patchNames.found(patchName))
|
||||
{
|
||||
if
|
||||
(
|
||||
writePatchField
|
||||
(
|
||||
vf.boundaryField()[patchi],
|
||||
patchi,
|
||||
ensightPatchI,
|
||||
boundaryFaceSets[patchi],
|
||||
nPatchPrims.find(patchName)(),
|
||||
ensightFile
|
||||
)
|
||||
)
|
||||
{
|
||||
ensightPatchI++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// write faceZones, if requested
|
||||
if (faceZoneNames.size())
|
||||
{
|
||||
// Interpolates cell values to faces - needed only when exporting
|
||||
// faceZones...
|
||||
GeometricField<Type, fvsPatchField, surfaceMesh> sf
|
||||
(
|
||||
linearInterpolate(vf)
|
||||
);
|
||||
|
||||
forAllConstIter(wordHashSet, faceZoneNames, iter)
|
||||
{
|
||||
const word& faceZoneName = iter.key();
|
||||
|
||||
eMesh.barrier();
|
||||
|
||||
label zoneID = mesh.faceZones().findZoneID(faceZoneName);
|
||||
|
||||
const faceZone& fz = mesh.faceZones()[zoneID];
|
||||
|
||||
// Prepare data to write
|
||||
label nIncluded = 0;
|
||||
forAll(fz, i)
|
||||
{
|
||||
if (eMesh.faceToBeIncluded(fz[i]))
|
||||
{
|
||||
++nIncluded;
|
||||
}
|
||||
}
|
||||
|
||||
Field<Type> values(nIncluded);
|
||||
|
||||
// Loop on the faceZone and store the needed field values
|
||||
label j = 0;
|
||||
forAll(fz, i)
|
||||
{
|
||||
label faceI = fz[i];
|
||||
if (mesh.isInternalFace(faceI))
|
||||
{
|
||||
values[j] = sf[faceI];
|
||||
++j;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (eMesh.faceToBeIncluded(faceI))
|
||||
{
|
||||
label patchI = mesh.boundaryMesh().whichPatch(faceI);
|
||||
const polyPatch& pp = mesh.boundaryMesh()[patchI];
|
||||
label patchFaceI = pp.whichFace(faceI);
|
||||
Type value = sf.boundaryField()[patchI][patchFaceI];
|
||||
values[j] = value;
|
||||
++j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
writePatchField
|
||||
(
|
||||
values,
|
||||
zoneID,
|
||||
ensightPatchI,
|
||||
faceZoneFaceSets[zoneID],
|
||||
nFaceZonePrims.find(faceZoneName)(),
|
||||
ensightFile
|
||||
)
|
||||
)
|
||||
{
|
||||
ensightPatchI++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Pstream::master())
|
||||
{
|
||||
delete ensightFilePtr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void ensightPointField
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& pf,
|
||||
const ensightMesh& eMesh,
|
||||
const fileName& postProcPath,
|
||||
const word& prepend,
|
||||
const label timeIndex,
|
||||
const bool binary,
|
||||
Ostream& ensightCaseFile
|
||||
)
|
||||
{
|
||||
Info<< "Converting field " << pf.name() << endl;
|
||||
|
||||
word timeFile = prepend + itoa(timeIndex);
|
||||
|
||||
const fvMesh& mesh = eMesh.mesh();
|
||||
const wordList& allPatchNames = eMesh.allPatchNames();
|
||||
const wordHashSet& patchNames = eMesh.patchNames();
|
||||
const wordHashSet& faceZoneNames = eMesh.faceZoneNames();
|
||||
|
||||
|
||||
ensightStream* ensightFilePtr = NULL;
|
||||
if (Pstream::master())
|
||||
{
|
||||
// set the filename of the ensight file
|
||||
fileName ensightFileName(timeFile + "." + pf.name());
|
||||
|
||||
if (binary)
|
||||
{
|
||||
ensightFilePtr = new ensightBinaryStream
|
||||
(
|
||||
postProcPath/ensightFileName,
|
||||
mesh.time()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
ensightFilePtr = new ensightAsciiStream
|
||||
(
|
||||
postProcPath/ensightFileName,
|
||||
mesh.time()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ensightStream& ensightFile = *ensightFilePtr;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
if (timeIndex == 0)
|
||||
{
|
||||
ensightCaseFile.setf(ios_base::left);
|
||||
|
||||
ensightCaseFile
|
||||
<< ensightPTraits<Type>::typeName
|
||||
<< " per node: 1 "
|
||||
<< setw(15) << pf.name()
|
||||
<< (' ' + prepend + "****." + pf.name()).c_str()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
ensightFile.write(ensightPTraits<Type>::typeName);
|
||||
}
|
||||
|
||||
if (eMesh.patchNames().empty())
|
||||
{
|
||||
eMesh.barrier();
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
ensightFile.writePartHeader(1);
|
||||
}
|
||||
|
||||
writeField
|
||||
(
|
||||
"coordinates",
|
||||
Field<Type>(pf.internalField(), eMesh.uniquePointMap()),
|
||||
ensightFile
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
label ensightPatchI = eMesh.patchPartOffset();
|
||||
|
||||
forAll(allPatchNames, patchi)
|
||||
{
|
||||
const word& patchName = allPatchNames[patchi];
|
||||
|
||||
eMesh.barrier();
|
||||
|
||||
if (patchNames.empty() || patchNames.found(patchName))
|
||||
{
|
||||
const fvPatch& p = mesh.boundary()[patchi];
|
||||
if
|
||||
(
|
||||
returnReduce(p.size(), sumOp<label>())
|
||||
> 0
|
||||
)
|
||||
{
|
||||
// Renumber the patch points/faces into unique points
|
||||
labelList pointToGlobal;
|
||||
labelList uniqueMeshPointLabels;
|
||||
autoPtr<globalIndex> globalPointsPtr =
|
||||
mesh.globalData().mergePoints
|
||||
(
|
||||
p.patch().meshPoints(),
|
||||
p.patch().meshPointMap(),
|
||||
pointToGlobal,
|
||||
uniqueMeshPointLabels
|
||||
);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
ensightFile.writePartHeader(ensightPatchI);
|
||||
}
|
||||
|
||||
writeField
|
||||
(
|
||||
"coordinates",
|
||||
Field<Type>(pf.internalField(), uniqueMeshPointLabels),
|
||||
ensightFile
|
||||
);
|
||||
|
||||
ensightPatchI++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// write faceZones, if requested
|
||||
if (faceZoneNames.size())
|
||||
{
|
||||
forAllConstIter(wordHashSet, faceZoneNames, iter)
|
||||
{
|
||||
const word& faceZoneName = iter.key();
|
||||
|
||||
eMesh.barrier();
|
||||
|
||||
label zoneID = mesh.faceZones().findZoneID(faceZoneName);
|
||||
|
||||
const faceZone& fz = mesh.faceZones()[zoneID];
|
||||
|
||||
if (returnReduce(fz().nPoints(), sumOp<label>()) > 0)
|
||||
{
|
||||
// Renumber the faceZone points/faces into unique points
|
||||
labelList pointToGlobal;
|
||||
labelList uniqueMeshPointLabels;
|
||||
autoPtr<globalIndex> globalPointsPtr =
|
||||
mesh.globalData().mergePoints
|
||||
(
|
||||
fz().meshPoints(),
|
||||
fz().meshPointMap(),
|
||||
pointToGlobal,
|
||||
uniqueMeshPointLabels
|
||||
);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
ensightFile.writePartHeader(ensightPatchI);
|
||||
}
|
||||
|
||||
writeField
|
||||
(
|
||||
"coordinates",
|
||||
Field<Type>
|
||||
(
|
||||
pf.internalField(),
|
||||
uniqueMeshPointLabels
|
||||
),
|
||||
ensightFile
|
||||
);
|
||||
|
||||
ensightPatchI++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
delete ensightFilePtr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void ensightField
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vf,
|
||||
const ensightMesh& eMesh,
|
||||
const fileName& postProcPath,
|
||||
const word& prepend,
|
||||
const label timeIndex,
|
||||
const bool binary,
|
||||
const bool nodeValues,
|
||||
Ostream& ensightCaseFile
|
||||
)
|
||||
{
|
||||
if (nodeValues)
|
||||
{
|
||||
tmp<GeometricField<Type, pointPatchField, pointMesh> > pfld
|
||||
(
|
||||
volPointInterpolation::New(vf.mesh()).interpolate(vf)
|
||||
);
|
||||
pfld().rename(vf.name());
|
||||
|
||||
ensightPointField<Type>
|
||||
(
|
||||
pfld,
|
||||
eMesh,
|
||||
postProcPath,
|
||||
prepend,
|
||||
timeIndex,
|
||||
binary,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
ensightField<Type>
|
||||
(
|
||||
vf,
|
||||
eMesh,
|
||||
postProcPath,
|
||||
prepend,
|
||||
timeIndex,
|
||||
binary,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,90 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InApplication
|
||||
foamToEnsight
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
ensightField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ensightField_H
|
||||
#define ensightField_H
|
||||
|
||||
#include "ensightMesh.H"
|
||||
#include "fvMeshSubset.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Wrapper to get hold of the field or the subsetted field
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
|
||||
volField
|
||||
(
|
||||
const Foam::fvMeshSubset&,
|
||||
const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>& vf
|
||||
);
|
||||
|
||||
|
||||
template<class Type>
|
||||
void ensightField
|
||||
(
|
||||
const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>& vf,
|
||||
const Foam::ensightMesh& eMesh,
|
||||
const Foam::fileName& postProcPath,
|
||||
const Foam::word& prepend,
|
||||
const Foam::label timeIndex,
|
||||
const bool binary,
|
||||
const bool nodeValues,
|
||||
Foam::Ostream& ensightCaseFile
|
||||
);
|
||||
|
||||
|
||||
template<class Type>
|
||||
void writePatchField
|
||||
(
|
||||
const Foam::word& fieldName,
|
||||
const Foam::Field<Type>& pf,
|
||||
const Foam::word& patchName,
|
||||
const Foam::ensightMesh& eMesh,
|
||||
const Foam::fileName& postProcPath,
|
||||
const Foam::word& prepend,
|
||||
const Foam::label timeIndex,
|
||||
Foam::Ostream& ensightCaseFile
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "ensightField.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,392 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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::ensightMesh
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
ensightMesh.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ensightMesh_H
|
||||
#define ensightMesh_H
|
||||
|
||||
#include "cellSets.H"
|
||||
#include "faceSets.H"
|
||||
#include "HashTable.H"
|
||||
#include "HashSet.H"
|
||||
#include "PackedBoolList.H"
|
||||
#include "wordReList.H"
|
||||
#include "scalarField.H"
|
||||
#include "cellShapeList.H"
|
||||
#include "cellList.H"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class fvMesh;
|
||||
class argList;
|
||||
class globalIndex;
|
||||
class ensightStream;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ensightMesh Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class ensightMesh
|
||||
{
|
||||
public:
|
||||
class nFacePrimitives
|
||||
{
|
||||
public:
|
||||
|
||||
label nTris;
|
||||
label nQuads;
|
||||
label nPolys;
|
||||
|
||||
nFacePrimitives()
|
||||
:
|
||||
nTris(0),
|
||||
nQuads(0),
|
||||
nPolys(0)
|
||||
{}
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Reference to the OpenFOAM mesh
|
||||
const fvMesh& mesh_;
|
||||
|
||||
//- Suppress patches
|
||||
const bool noPatches_;
|
||||
|
||||
//- Output selected patches only
|
||||
const bool patches_;
|
||||
const wordReList patchPatterns_;
|
||||
|
||||
//- Output selected faceZones
|
||||
const bool faceZones_;
|
||||
const wordReList faceZonePatterns_;
|
||||
|
||||
//- Set binary file output
|
||||
const bool binary_;
|
||||
|
||||
//- The ensight part id for the first patch
|
||||
label patchPartOffset_;
|
||||
|
||||
cellSets meshCellSets_;
|
||||
|
||||
List<faceSets> boundaryFaceSets_;
|
||||
|
||||
wordList allPatchNames_;
|
||||
|
||||
wordHashSet patchNames_;
|
||||
|
||||
HashTable<nFacePrimitives> nPatchPrims_;
|
||||
|
||||
// faceZone - related variables
|
||||
List<faceSets> faceZoneFaceSets_;
|
||||
|
||||
wordHashSet faceZoneNames_;
|
||||
|
||||
HashTable<nFacePrimitives> nFaceZonePrims_;
|
||||
|
||||
//- Per boundary face whether to include or not
|
||||
PackedBoolList boundaryFaceToBeIncluded_;
|
||||
|
||||
|
||||
// Parallel merged points
|
||||
|
||||
//- Global numbering for merged points
|
||||
autoPtr<globalIndex> globalPointsPtr_;
|
||||
|
||||
//- From mesh point to global merged point
|
||||
labelList pointToGlobal_;
|
||||
|
||||
//- Local points that are unique
|
||||
labelList uniquePointMap_;
|
||||
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
ensightMesh(const ensightMesh&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const ensightMesh&);
|
||||
|
||||
void writePoints
|
||||
(
|
||||
const scalarField& pointsComponent,
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
cellShapeList map
|
||||
(
|
||||
const cellShapeList& cellShapes,
|
||||
const labelList& prims,
|
||||
const labelList& pointToGlobal
|
||||
) const;
|
||||
|
||||
cellShapeList map
|
||||
(
|
||||
const cellShapeList& cellShapes,
|
||||
const labelList& hexes,
|
||||
const labelList& wedges,
|
||||
const labelList& pointToGlobal
|
||||
) const;
|
||||
|
||||
void writePrims
|
||||
(
|
||||
const cellShapeList& cellShapes,
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writePolysNFaces
|
||||
(
|
||||
const labelList& polys,
|
||||
const cellList& cellFaces,
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writePolysNPointsPerFace
|
||||
(
|
||||
const labelList& polys,
|
||||
const cellList& cellFaces,
|
||||
const faceList& faces,
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writePolysPoints
|
||||
(
|
||||
const labelList& polys,
|
||||
const cellList& cellFaces,
|
||||
const faceList& faces,
|
||||
const labelList& faceOwner,
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllPolys
|
||||
(
|
||||
const labelList& pointToGlobal,
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllPrims
|
||||
(
|
||||
const char* key,
|
||||
const label nPrims,
|
||||
const cellShapeList& cellShapes,
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeFacePrims
|
||||
(
|
||||
const faceList& patchFaces,
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllFacePrims
|
||||
(
|
||||
const char* key,
|
||||
const labelList& prims,
|
||||
const label nPrims,
|
||||
const faceList& patchFaces,
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeNSidedNPointsPerFace
|
||||
(
|
||||
const faceList& patchFaces,
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeNSidedPoints
|
||||
(
|
||||
const faceList& patchFaces,
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllNSided
|
||||
(
|
||||
const labelList& prims,
|
||||
const label nPrims,
|
||||
const faceList& patchFaces,
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
void writeAllPoints
|
||||
(
|
||||
const label ensightPartI,
|
||||
const word& ensightPartName,
|
||||
const pointField& uniquePoints,
|
||||
const label nPoints,
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from fvMesh
|
||||
ensightMesh
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const bool noPatches,
|
||||
const bool patches,
|
||||
const wordReList& patchPatterns,
|
||||
const bool faceZones,
|
||||
const wordReList& faceZonePatterns,
|
||||
const bool binary
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~ensightMesh();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
const fvMesh& mesh() const
|
||||
{
|
||||
return mesh_;
|
||||
}
|
||||
|
||||
const cellSets& meshCellSets() const
|
||||
{
|
||||
return meshCellSets_;
|
||||
}
|
||||
|
||||
const List<faceSets>& boundaryFaceSets() const
|
||||
{
|
||||
return boundaryFaceSets_;
|
||||
}
|
||||
|
||||
const wordList& allPatchNames() const
|
||||
{
|
||||
return allPatchNames_;
|
||||
}
|
||||
|
||||
const wordHashSet& patchNames() const
|
||||
{
|
||||
return patchNames_;
|
||||
}
|
||||
|
||||
const HashTable<nFacePrimitives>& nPatchPrims() const
|
||||
{
|
||||
return nPatchPrims_;
|
||||
}
|
||||
|
||||
const List<faceSets>& faceZoneFaceSets() const
|
||||
{
|
||||
return faceZoneFaceSets_;
|
||||
}
|
||||
|
||||
const wordHashSet& faceZoneNames() const
|
||||
{
|
||||
return faceZoneNames_;
|
||||
}
|
||||
|
||||
const HashTable<nFacePrimitives>& nFaceZonePrims() const
|
||||
{
|
||||
return nFaceZonePrims_;
|
||||
}
|
||||
|
||||
//- The ensight part id for the first patch
|
||||
label patchPartOffset() const
|
||||
{
|
||||
return patchPartOffset_;
|
||||
}
|
||||
|
||||
|
||||
// Parallel point merging
|
||||
|
||||
//- Global numbering for merged points
|
||||
const globalIndex& globalPoints() const
|
||||
{
|
||||
return globalPointsPtr_();
|
||||
}
|
||||
|
||||
//- From mesh point to global merged point
|
||||
const labelList& pointToGlobal() const
|
||||
{
|
||||
return pointToGlobal_;
|
||||
}
|
||||
|
||||
//- Local points that are unique
|
||||
const labelList& uniquePointMap() const
|
||||
{
|
||||
return uniquePointMap_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Other
|
||||
|
||||
//- Update for new mesh
|
||||
void correct();
|
||||
|
||||
//- When exporting faceZones, check if a given face has to be included
|
||||
// or not (i.e. faces on processor boundaries)
|
||||
bool faceToBeIncluded(const label faceI) const;
|
||||
|
||||
//- Helper to cause barrier. Necessary on Quadrics.
|
||||
static void barrier();
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
void write
|
||||
(
|
||||
const fileName& postProcPath,
|
||||
const word& prepend,
|
||||
const label timeIndex,
|
||||
const bool meshMoving,
|
||||
Ostream& ensightCaseFile
|
||||
) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,103 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "ensightParticlePositions.H"
|
||||
#include "fvMesh.H"
|
||||
#include "passiveParticle.H"
|
||||
#include "Cloud.H"
|
||||
#include "OFstream.H"
|
||||
#include "IOmanip.H"
|
||||
#include "itoa.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
void ensightParticlePositions
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const fileName& postProcPath,
|
||||
const word& timeFile,
|
||||
const word& cloudName,
|
||||
const bool dataExists
|
||||
)
|
||||
{
|
||||
if (dataExists)
|
||||
{
|
||||
Info<< "Converting cloud " << cloudName << " positions" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Creating empty cloud " << cloudName << " positions" << endl;
|
||||
}
|
||||
|
||||
const Time& runTime = mesh.time();
|
||||
|
||||
fileName ensightFileName(timeFile + "." + cloudName);
|
||||
OFstream ensightFile
|
||||
(
|
||||
postProcPath/ensightFileName,
|
||||
runTime.writeFormat(),
|
||||
runTime.writeVersion(),
|
||||
runTime.writeCompression()
|
||||
);
|
||||
|
||||
// Output header
|
||||
ensightFile
|
||||
<< cloudName.c_str() << nl
|
||||
<< "particle coordinates" << nl;
|
||||
|
||||
if (dataExists)
|
||||
{
|
||||
Cloud<passiveParticle> parcels(mesh, cloudName, false);
|
||||
|
||||
// Set Format
|
||||
ensightFile.setf(ios_base::scientific, ios_base::floatfield);
|
||||
ensightFile.precision(5);
|
||||
|
||||
ensightFile<< setw(8) << parcels.size() << nl;
|
||||
|
||||
label nParcels = 0;
|
||||
|
||||
// Output positions
|
||||
forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
|
||||
{
|
||||
const vector& p = elmnt().position();
|
||||
|
||||
ensightFile
|
||||
<< setw(8) << ++nParcels
|
||||
<< setw(12) << p.x() << setw(12) << p.y() << setw(12) << p.z()
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
label nParcels = 0;
|
||||
ensightFile<< setw(8) << nParcels << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InApplication
|
||||
foamToEnsight
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
ensightParticlePositions.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ensightParticlePositions_H
|
||||
#define ensightParticlePositions_H
|
||||
|
||||
#include "fvMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void ensightParticlePositions
|
||||
(
|
||||
const Foam::fvMesh& mesh,
|
||||
const Foam::fileName& postProcPath,
|
||||
const Foam::word& timeFile,
|
||||
const Foam::word& CloudName,
|
||||
const bool dataExists
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,114 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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::ensightStream
|
||||
|
||||
Description
|
||||
Abstract base class for writing Ensight data
|
||||
|
||||
SourceFiles
|
||||
ensightStream.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ensightStream_H
|
||||
#define ensightStream_H
|
||||
|
||||
#include "fileName.H"
|
||||
#include "scalarField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ensightStream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class ensightStream
|
||||
{
|
||||
// Private data
|
||||
|
||||
const fileName name_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
ensightStream(const ensightStream&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const ensightStream&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
ensightStream(const fileName& f)
|
||||
:
|
||||
name_(f)
|
||||
{}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ensightStream()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
const fileName& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
virtual bool ascii() const = 0;
|
||||
|
||||
virtual void write(const char*) = 0;
|
||||
|
||||
virtual void write(const int) = 0;
|
||||
|
||||
virtual void write(const scalarField&) = 0;
|
||||
|
||||
virtual void write(const List<int>&) = 0;
|
||||
|
||||
virtual void writePartHeader(const label) = 0;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,78 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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::faceSets
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef faceSets_H
|
||||
#define faceSets_H
|
||||
|
||||
#include "labelList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class faceSets Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class faceSets
|
||||
{
|
||||
public:
|
||||
|
||||
label nTris;
|
||||
label nQuads;
|
||||
label nPolys;
|
||||
|
||||
labelList tris;
|
||||
labelList quads;
|
||||
labelList polys;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
faceSets()
|
||||
:
|
||||
nTris(0),
|
||||
nQuads(0),
|
||||
nPolys(0)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,636 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Application
|
||||
foamToEnsight
|
||||
|
||||
Description
|
||||
Translates OpenFOAM data to EnSight format.
|
||||
|
||||
An Ensight part is created for the internalMesh and for each patch.
|
||||
|
||||
Usage
|
||||
- foamToEnsight [OPTION] \n
|
||||
Translates OpenFOAM data to Ensight format
|
||||
|
||||
\param -ascii \n
|
||||
Write Ensight data in ASCII format instead of "C Binary"
|
||||
|
||||
\param -patches patchList \n
|
||||
Specify particular patches to write.
|
||||
Specifying an empty list suppresses writing the internalMesh.
|
||||
|
||||
\param -noPatches \n
|
||||
Suppress writing any patches.
|
||||
|
||||
\param -faceZones zoneList \n
|
||||
Specify faceZones to write, with wildcards
|
||||
|
||||
\param -cellZone zoneName \n
|
||||
Specify single cellZone to write (not lagrangian)
|
||||
|
||||
Note
|
||||
Parallel support for cloud data is not supported
|
||||
- writes to \a EnSight directory to avoid collisions with foamToEnsightParts
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "IOmanip.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
#include "volFields.H"
|
||||
|
||||
#include "labelIOField.H"
|
||||
#include "scalarIOField.H"
|
||||
#include "tensorIOField.H"
|
||||
|
||||
#include "ensightMesh.H"
|
||||
#include "ensightField.H"
|
||||
|
||||
#include "ensightParticlePositions.H"
|
||||
#include "ensightCloudField.H"
|
||||
|
||||
#include "fvc.H"
|
||||
|
||||
#include "cellSet.H"
|
||||
#include "fvMeshSubset.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
bool inFileNameList
|
||||
(
|
||||
const fileNameList& nameList,
|
||||
const word& name
|
||||
)
|
||||
{
|
||||
forAll(nameList, i)
|
||||
{
|
||||
if (nameList[i] == name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
timeSelector::addOptions();
|
||||
#include "addRegionOption.H"
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"ascii",
|
||||
"write in ASCII format instead of 'C Binary'"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"nodeValues",
|
||||
"write values in nodes"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"noPatches",
|
||||
"suppress writing any patches"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"patches",
|
||||
"wordReList",
|
||||
"specify particular patches to write - eg '(outlet \"inlet.*\")'. "
|
||||
"An empty list suppresses writing the internalMesh."
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"faceZones",
|
||||
"wordReList",
|
||||
"specify faceZones to write - eg '( slice \"mfp-.*\" )'."
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"fields",
|
||||
"wordReList",
|
||||
"specify fields to export (all by default) - eg '( \"U.*\" )'."
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"cellZone",
|
||||
"word",
|
||||
"specify cellZone to write"
|
||||
);
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
// Check options
|
||||
const bool binary = !args.optionFound("ascii");
|
||||
const bool nodeValues = args.optionFound("nodeValues");
|
||||
|
||||
#include "createTime.H"
|
||||
|
||||
instantList Times = timeSelector::select0(runTime, args);
|
||||
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
// Mesh instance (region0 gets filtered out)
|
||||
fileName regionPrefix = "";
|
||||
|
||||
if (regionName != polyMesh::defaultRegion)
|
||||
{
|
||||
regionPrefix = regionName;
|
||||
}
|
||||
|
||||
const label nVolFieldTypes = 5;
|
||||
const word volFieldTypes[] =
|
||||
{
|
||||
volScalarField::typeName,
|
||||
volVectorField::typeName,
|
||||
volSphericalTensorField::typeName,
|
||||
volSymmTensorField::typeName,
|
||||
volTensorField::typeName
|
||||
};
|
||||
|
||||
// Path to EnSight directory at case level only
|
||||
// - For parallel cases, data only written from master
|
||||
fileName ensightDir = args.rootPath()/args.globalCaseName()/"EnSight";
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
if (isDir(ensightDir))
|
||||
{
|
||||
rmDir(ensightDir);
|
||||
}
|
||||
|
||||
mkDir(ensightDir);
|
||||
}
|
||||
|
||||
// Start of case file header output
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
const word prepend = args.globalCaseName() + '.';
|
||||
|
||||
OFstream *ensightCaseFilePtr = NULL;
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName caseFileName = prepend + "case";
|
||||
Info<< nl << "write case: " << caseFileName.c_str() << endl;
|
||||
|
||||
// the case file is always ASCII
|
||||
ensightCaseFilePtr = new OFstream
|
||||
(
|
||||
ensightDir/caseFileName,
|
||||
IOstream::ASCII
|
||||
);
|
||||
|
||||
*ensightCaseFilePtr
|
||||
<< "FORMAT" << nl
|
||||
<< "type: ensight gold" << nl << nl;
|
||||
}
|
||||
|
||||
OFstream& ensightCaseFile = *ensightCaseFilePtr;
|
||||
|
||||
// Construct the EnSight mesh
|
||||
const bool selectedPatches = args.optionFound("patches");
|
||||
wordReList patchPatterns;
|
||||
if (selectedPatches)
|
||||
{
|
||||
patchPatterns = wordReList(args.optionLookup("patches")());
|
||||
}
|
||||
const bool selectedZones = args.optionFound("faceZones");
|
||||
wordReList zonePatterns;
|
||||
if (selectedZones)
|
||||
{
|
||||
zonePatterns = wordReList(args.optionLookup("faceZones")());
|
||||
}
|
||||
|
||||
const bool selectedFields = args.optionFound("fields");
|
||||
wordReList fieldPatterns;
|
||||
if (selectedFields)
|
||||
{
|
||||
fieldPatterns = wordReList(args.optionLookup("fields")());
|
||||
}
|
||||
|
||||
word cellZoneName;
|
||||
const bool doCellZone = args.optionReadIfPresent("cellZone", cellZoneName);
|
||||
|
||||
fvMeshSubset meshSubsetter(mesh);
|
||||
if (doCellZone)
|
||||
{
|
||||
Info<< "Converting cellZone " << cellZoneName
|
||||
<< " only (puts outside faces into patch "
|
||||
<< mesh.boundaryMesh()[0].name()
|
||||
<< ")" << endl;
|
||||
const cellZone& cz = mesh.cellZones()[cellZoneName];
|
||||
cellSet c0(mesh, "c0", labelHashSet(cz));
|
||||
meshSubsetter.setLargeCellSubset(c0, 0);
|
||||
}
|
||||
|
||||
ensightMesh eMesh
|
||||
(
|
||||
(
|
||||
meshSubsetter.hasSubMesh()
|
||||
? meshSubsetter.subMesh()
|
||||
: meshSubsetter.baseMesh()
|
||||
),
|
||||
args.optionFound("noPatches"),
|
||||
selectedPatches,
|
||||
patchPatterns,
|
||||
selectedZones,
|
||||
zonePatterns,
|
||||
binary
|
||||
);
|
||||
|
||||
// Set Time to the last time before looking for the lagrangian objects
|
||||
runTime.setTime(Times.last(), Times.size()-1);
|
||||
|
||||
IOobjectList objects(mesh, runTime.timeName());
|
||||
|
||||
#include "checkMeshMoving.H"
|
||||
|
||||
if (meshMoving)
|
||||
{
|
||||
Info<< "Detected a moving mesh (multiple polyMesh/points files)."
|
||||
<< " Writing meshes for every timestep." << endl;
|
||||
}
|
||||
|
||||
|
||||
wordHashSet allCloudNames;
|
||||
if (Pstream::master())
|
||||
{
|
||||
word geomFileName = prepend + "0000";
|
||||
|
||||
// test pre check variable if there is a moving mesh
|
||||
if (meshMoving)
|
||||
{
|
||||
geomFileName = prepend + "****";
|
||||
}
|
||||
|
||||
ensightCaseFile
|
||||
<< "GEOMETRY" << nl
|
||||
<< "model: 1 "
|
||||
<< (geomFileName + ".mesh").c_str() << nl;
|
||||
}
|
||||
|
||||
// Identify if lagrangian data exists at each time, and add clouds
|
||||
// to the 'allCloudNames' hash set
|
||||
forAll(Times, timeI)
|
||||
{
|
||||
runTime.setTime(Times[timeI], timeI);
|
||||
|
||||
fileNameList cloudDirs = readDir
|
||||
(
|
||||
runTime.timePath()/regionPrefix/cloud::prefix,
|
||||
fileName::DIRECTORY
|
||||
);
|
||||
|
||||
forAll(cloudDirs, cloudI)
|
||||
{
|
||||
IOobjectList cloudObjs
|
||||
(
|
||||
mesh,
|
||||
runTime.timeName(),
|
||||
cloud::prefix/cloudDirs[cloudI]
|
||||
);
|
||||
|
||||
IOobject* positionsPtr = cloudObjs.lookup(word("positions"));
|
||||
|
||||
if (positionsPtr)
|
||||
{
|
||||
allCloudNames.insert(cloudDirs[cloudI]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashTable<HashTable<word> > allCloudFields;
|
||||
forAllConstIter(wordHashSet, allCloudNames, cloudIter)
|
||||
{
|
||||
// Add the name of the cloud(s) to the case file header
|
||||
if (Pstream::master())
|
||||
{
|
||||
ensightCaseFile
|
||||
<< (
|
||||
"measured: 1 "
|
||||
+ prepend
|
||||
+ "****."
|
||||
+ cloudIter.key()
|
||||
).c_str()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
// Create a new hash table for each cloud
|
||||
allCloudFields.insert(cloudIter.key(), HashTable<word>());
|
||||
|
||||
// Identify the new cloud in the hash table
|
||||
HashTable<HashTable<word> >::iterator newCloudIter =
|
||||
allCloudFields.find(cloudIter.key());
|
||||
|
||||
// Loop over all times to build list of fields and field types
|
||||
// for each cloud
|
||||
forAll(Times, timeI)
|
||||
{
|
||||
runTime.setTime(Times[timeI], timeI);
|
||||
|
||||
IOobjectList cloudObjs
|
||||
(
|
||||
mesh,
|
||||
runTime.timeName(),
|
||||
cloud::prefix/cloudIter.key()
|
||||
);
|
||||
|
||||
forAllConstIter(IOobjectList, cloudObjs, fieldIter)
|
||||
{
|
||||
const IOobject obj = *fieldIter();
|
||||
|
||||
if (obj.name() != "positions")
|
||||
{
|
||||
// Add field and field type
|
||||
newCloudIter().insert
|
||||
(
|
||||
obj.name(),
|
||||
obj.headerClassName()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
label nTimeSteps = 0;
|
||||
forAll(Times, timeIndex)
|
||||
{
|
||||
nTimeSteps++;
|
||||
runTime.setTime(Times[timeIndex], timeIndex);
|
||||
|
||||
word timeName = itoa(timeIndex);
|
||||
word timeFile = prepend + timeName;
|
||||
|
||||
Info<< "Translating time = " << runTime.timeName() << nl;
|
||||
|
||||
polyMesh::readUpdateState meshState = mesh.readUpdate();
|
||||
if (timeIndex != 0 && meshSubsetter.hasSubMesh())
|
||||
{
|
||||
Info<< "Converting cellZone " << cellZoneName
|
||||
<< " only (puts outside faces into patch "
|
||||
<< mesh.boundaryMesh()[0].name()
|
||||
<< ")" << endl;
|
||||
const cellZone& cz = mesh.cellZones()[cellZoneName];
|
||||
cellSet c0(mesh, "c0", labelHashSet(cz));
|
||||
meshSubsetter.setLargeCellSubset(c0, 0);
|
||||
}
|
||||
|
||||
|
||||
if (meshState != polyMesh::UNCHANGED)
|
||||
{
|
||||
eMesh.correct();
|
||||
}
|
||||
|
||||
if (timeIndex == 0 || meshMoving)
|
||||
{
|
||||
eMesh.write
|
||||
(
|
||||
ensightDir,
|
||||
prepend,
|
||||
timeIndex,
|
||||
meshMoving,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Start of field data output
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
if (timeIndex == 0 && Pstream::master())
|
||||
{
|
||||
ensightCaseFile<< nl << "VARIABLE" << nl;
|
||||
}
|
||||
|
||||
|
||||
// Cell field data output
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
for (label i=0; i<nVolFieldTypes; i++)
|
||||
{
|
||||
wordList fieldNames = objects.names(volFieldTypes[i]);
|
||||
|
||||
forAll(fieldNames, j)
|
||||
{
|
||||
const word& fieldName = fieldNames[j];
|
||||
|
||||
// Check if the field has to be exported
|
||||
if (selectedFields)
|
||||
{
|
||||
if (!findStrings(fieldPatterns, fieldName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
#include "checkData.H"
|
||||
|
||||
if (!variableGood)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IOobject fieldObject
|
||||
(
|
||||
fieldName,
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
if (volFieldTypes[i] == volScalarField::typeName)
|
||||
{
|
||||
volScalarField vf(fieldObject, mesh);
|
||||
ensightField<scalar>
|
||||
(
|
||||
volField(meshSubsetter, vf),
|
||||
eMesh,
|
||||
ensightDir,
|
||||
prepend,
|
||||
timeIndex,
|
||||
binary,
|
||||
nodeValues,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
else if (volFieldTypes[i] == volVectorField::typeName)
|
||||
{
|
||||
volVectorField vf(fieldObject, mesh);
|
||||
ensightField<vector>
|
||||
(
|
||||
volField(meshSubsetter, vf),
|
||||
eMesh,
|
||||
ensightDir,
|
||||
prepend,
|
||||
timeIndex,
|
||||
binary,
|
||||
nodeValues,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
else if (volFieldTypes[i] == volSphericalTensorField::typeName)
|
||||
{
|
||||
volSphericalTensorField vf(fieldObject, mesh);
|
||||
ensightField<sphericalTensor>
|
||||
(
|
||||
volField(meshSubsetter, vf),
|
||||
eMesh,
|
||||
ensightDir,
|
||||
prepend,
|
||||
timeIndex,
|
||||
binary,
|
||||
nodeValues,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
else if (volFieldTypes[i] == volSymmTensorField::typeName)
|
||||
{
|
||||
volSymmTensorField vf(fieldObject, mesh);
|
||||
ensightField<symmTensor>
|
||||
(
|
||||
volField(meshSubsetter, vf),
|
||||
eMesh,
|
||||
ensightDir,
|
||||
prepend,
|
||||
timeIndex,
|
||||
binary,
|
||||
nodeValues,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
else if (volFieldTypes[i] == volTensorField::typeName)
|
||||
{
|
||||
volTensorField vf(fieldObject, mesh);
|
||||
ensightField<tensor>
|
||||
(
|
||||
volField(meshSubsetter, vf),
|
||||
eMesh,
|
||||
ensightDir,
|
||||
prepend,
|
||||
timeIndex,
|
||||
binary,
|
||||
nodeValues,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Cloud field data output
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
forAllConstIter(HashTable<HashTable<word> >, allCloudFields, cloudIter)
|
||||
{
|
||||
const word& cloudName = cloudIter.key();
|
||||
|
||||
fileNameList currentCloudDirs = readDir
|
||||
(
|
||||
runTime.timePath()/regionPrefix/cloud::prefix,
|
||||
fileName::DIRECTORY
|
||||
);
|
||||
|
||||
bool cloudExists = inFileNameList(currentCloudDirs, cloudName);
|
||||
ensightParticlePositions
|
||||
(
|
||||
mesh,
|
||||
ensightDir,
|
||||
timeFile,
|
||||
cloudName,
|
||||
cloudExists
|
||||
);
|
||||
|
||||
forAllConstIter(HashTable<word>, cloudIter(), fieldIter)
|
||||
{
|
||||
const word& fieldName = fieldIter.key();
|
||||
const word& fieldType = fieldIter();
|
||||
|
||||
IOobject fieldObject
|
||||
(
|
||||
fieldName,
|
||||
mesh.time().timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
bool fieldExists = fieldObject.headerOk();
|
||||
if (fieldType == scalarIOField::typeName)
|
||||
{
|
||||
ensightCloudField<scalar>
|
||||
(
|
||||
fieldObject,
|
||||
ensightDir,
|
||||
prepend,
|
||||
timeIndex,
|
||||
cloudName,
|
||||
ensightCaseFile,
|
||||
fieldExists
|
||||
);
|
||||
}
|
||||
else if (fieldType == vectorIOField::typeName)
|
||||
{
|
||||
ensightCloudField<vector>
|
||||
(
|
||||
fieldObject,
|
||||
ensightDir,
|
||||
prepend,
|
||||
timeIndex,
|
||||
cloudName,
|
||||
ensightCaseFile,
|
||||
fieldExists
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Unable to convert field type " << fieldType
|
||||
<< " for field " << fieldName << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "ensightCaseTail.H"
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
delete ensightCaseFilePtr;
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,61 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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 "itoa.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
word itoa(const label n)
|
||||
{
|
||||
const label offset = '0';
|
||||
const label length = 4;
|
||||
|
||||
char val[length + 1];
|
||||
|
||||
label leftOfN = n;
|
||||
|
||||
for (label i=0; i<length; i++)
|
||||
{
|
||||
label j = label(leftOfN/pow(10, length - i - 1));
|
||||
leftOfN -= j*pow(10, length - i - 1);
|
||||
val[i] = offset + j;
|
||||
}
|
||||
|
||||
val[length] = 0;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,47 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InApplication
|
||||
foamToEnsight
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "word.H"
|
||||
#include "label.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
word itoa(const label n);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,3 @@
|
||||
foamToEnsightParts.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/foamToEnsightParts
|
||||
@ -0,0 +1,12 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/conversion/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-llagrangian \
|
||||
-lmeshTools \
|
||||
-lgenericPatchFields \
|
||||
-lconversion
|
||||
@ -0,0 +1,18 @@
|
||||
// check for "points" in all of the result directories
|
||||
|
||||
bool hasMovingMesh = false;
|
||||
if (timeDirs.size() > 1)
|
||||
{
|
||||
hasMovingMesh = true;
|
||||
for (label i=0; i < timeDirs.size() && hasMovingMesh; ++i)
|
||||
{
|
||||
hasMovingMesh = IOobject
|
||||
(
|
||||
"points",
|
||||
timeDirs[i].name(),
|
||||
polyMesh::meshSubDir,
|
||||
mesh,
|
||||
IOobject::NO_READ
|
||||
).headerOk();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,224 @@
|
||||
// write time values to case file
|
||||
|
||||
scalar timeCorrection = 0;
|
||||
if (timeDirs[0].value() < 0)
|
||||
{
|
||||
timeCorrection = - timeDirs[0].value();
|
||||
Info<< "Correcting time values. Adding " << timeCorrection << endl;
|
||||
}
|
||||
|
||||
// the case file is always ASCII
|
||||
Info << "write case: " << caseFileName.c_str() << endl;
|
||||
|
||||
OFstream caseFile(ensightDir/caseFileName, IOstream::ASCII);
|
||||
caseFile.setf(ios_base::left);
|
||||
|
||||
caseFile.setf(ios_base::scientific, ios_base::floatfield);
|
||||
caseFile.precision(5);
|
||||
|
||||
caseFile
|
||||
<< "FORMAT" << nl
|
||||
<< setw(16) << "type:" << "ensight gold" << nl << nl;
|
||||
|
||||
if (hasMovingMesh)
|
||||
{
|
||||
caseFile
|
||||
<< "GEOMETRY" << nl
|
||||
<< setw(16) << "model: 1" << (dataMask/geometryName).c_str() << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
caseFile
|
||||
<< "GEOMETRY" << nl
|
||||
<< setw(16) << "model:" << geometryName << nl;
|
||||
}
|
||||
|
||||
|
||||
// add information for clouds
|
||||
// multiple clouds currently require the same time index
|
||||
forAllConstIter(HashTable<HashTable<word> >, cloudFields, cloudIter)
|
||||
{
|
||||
const word& cloudName = cloudIter.key();
|
||||
|
||||
caseFile
|
||||
<< setw(16) << "measured: 2"
|
||||
<< fileName(dataMask/cloud::prefix/cloudName/"positions").c_str()
|
||||
<< nl;
|
||||
}
|
||||
caseFile
|
||||
<< nl << "VARIABLE" << nl;
|
||||
|
||||
forAllConstIter(HashTable<word>, volumeFields, fieldIter)
|
||||
{
|
||||
const word& fieldName = fieldIter.key();
|
||||
const word& fieldType = fieldIter();
|
||||
string ensightType;
|
||||
|
||||
if (fieldType == volScalarField::typeName)
|
||||
{
|
||||
ensightType = "scalar";
|
||||
}
|
||||
else if (fieldType == volVectorField::typeName)
|
||||
{
|
||||
ensightType = "vector";
|
||||
}
|
||||
else if (fieldType == volSphericalTensorField::typeName)
|
||||
{
|
||||
ensightType = "tensor symm";
|
||||
}
|
||||
else if (fieldType == volSymmTensorField::typeName)
|
||||
{
|
||||
ensightType = "tensor symm";
|
||||
}
|
||||
else if (fieldType == volTensorField::typeName)
|
||||
{
|
||||
ensightType = "tensor asym";
|
||||
}
|
||||
|
||||
if (ensightType.size())
|
||||
{
|
||||
ensightCaseEntry
|
||||
(
|
||||
caseFile,
|
||||
ensightType,
|
||||
fieldName,
|
||||
dataMask
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: allow similar/different time-steps for each cloud
|
||||
|
||||
|
||||
label cloudNo = 0;
|
||||
forAllConstIter(HashTable<HashTable<word> >, cloudFields, cloudIter)
|
||||
{
|
||||
const word& cloudName = cloudIter.key();
|
||||
|
||||
forAllConstIter(HashTable<word>, cloudIter(), fieldIter)
|
||||
{
|
||||
const word& fieldName = fieldIter.key();
|
||||
const word& fieldType = fieldIter();
|
||||
string ensightType;
|
||||
|
||||
if (fieldType == scalarIOField::typeName)
|
||||
{
|
||||
ensightType = "scalar";
|
||||
}
|
||||
else if (fieldType == vectorIOField::typeName)
|
||||
{
|
||||
ensightType = "vector";
|
||||
}
|
||||
else if (fieldType == tensorIOField::typeName)
|
||||
{
|
||||
ensightType = "tensor";
|
||||
}
|
||||
|
||||
if (ensightType.size())
|
||||
{
|
||||
ensightCaseEntry
|
||||
(
|
||||
caseFile,
|
||||
ensightType,
|
||||
fieldName,
|
||||
dataMask,
|
||||
cloud::prefix/cloudName,
|
||||
cloudNo,
|
||||
2
|
||||
);
|
||||
}
|
||||
}
|
||||
cloudNo++;
|
||||
}
|
||||
|
||||
|
||||
// add time values
|
||||
caseFile << nl << "TIME" << nl;
|
||||
|
||||
// time set 1 - geometry and volume fields
|
||||
if (fieldTimesUsed.size())
|
||||
{
|
||||
caseFile
|
||||
<< "time set: " << 1 << nl
|
||||
<< "number of steps: " << fieldTimesUsed.size() << nl
|
||||
<< "filename numbers:" << nl;
|
||||
|
||||
label count = 0;
|
||||
forAll(fieldTimesUsed, i)
|
||||
{
|
||||
caseFile
|
||||
<< " " << setw(12) << fieldTimesUsed[i];
|
||||
|
||||
if (++count % 6 == 0)
|
||||
{
|
||||
caseFile << nl;
|
||||
}
|
||||
}
|
||||
|
||||
caseFile
|
||||
<< nl << "time values:" << nl;
|
||||
|
||||
count = 0;
|
||||
forAll(fieldTimesUsed, i)
|
||||
{
|
||||
caseFile
|
||||
<< " " << setw(12)
|
||||
<< timeIndices[fieldTimesUsed[i]] + timeCorrection;
|
||||
|
||||
if (++count % 6 == 0)
|
||||
{
|
||||
caseFile << nl;
|
||||
}
|
||||
}
|
||||
caseFile << nl << nl;
|
||||
}
|
||||
|
||||
// TODO: allow similar/different time-steps for each cloud
|
||||
cloudNo = 0;
|
||||
forAllConstIter(HashTable<DynamicList<label> >, cloudTimesUsed, cloudIter)
|
||||
{
|
||||
// const word& cloudName = cloudIter.key();
|
||||
const DynamicList<label>& timesUsed = cloudIter();
|
||||
|
||||
if (timesUsed.size() && cloudNo == 0)
|
||||
{
|
||||
caseFile
|
||||
<< "time set: " << 2 << nl
|
||||
<< "number of steps: " << timesUsed.size() << nl
|
||||
<< "filename numbers:" << nl;
|
||||
|
||||
label count = 0;
|
||||
forAll(timesUsed, i)
|
||||
{
|
||||
caseFile
|
||||
<< " " << setw(12) << timesUsed[i];
|
||||
|
||||
if (++count % 6 == 0)
|
||||
{
|
||||
caseFile << nl;
|
||||
}
|
||||
}
|
||||
|
||||
caseFile
|
||||
<< nl << "time values:" << nl;
|
||||
|
||||
count = 0;
|
||||
forAll(timesUsed, i)
|
||||
{
|
||||
caseFile
|
||||
<< " " << setw(12)
|
||||
<< timeIndices[timesUsed[i]] + timeCorrection;
|
||||
|
||||
if (++count % 6 == 0)
|
||||
{
|
||||
caseFile << nl;
|
||||
}
|
||||
}
|
||||
caseFile << nl << nl;
|
||||
|
||||
cloudNo++;
|
||||
}
|
||||
}
|
||||
|
||||
caseFile << "# end" << nl;
|
||||
|
||||
@ -0,0 +1,242 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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 "ensightOutputFunctions.H"
|
||||
|
||||
#include "passiveParticle.H"
|
||||
#include "IOField.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
|
||||
#include "OFstream.H"
|
||||
#include "IOmanip.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::ensightCaseEntry
|
||||
(
|
||||
OFstream& caseFile,
|
||||
const string& ensightType,
|
||||
const word& fieldName,
|
||||
const fileName& dataMask,
|
||||
const fileName& local,
|
||||
const label cloudNo,
|
||||
const label timeSet
|
||||
)
|
||||
{
|
||||
caseFile.setf(ios_base::left);
|
||||
|
||||
fileName dirName(dataMask);
|
||||
if (local.size())
|
||||
{
|
||||
dirName = dirName/local;
|
||||
}
|
||||
|
||||
if (cloudNo >= 0)
|
||||
{
|
||||
label ts = 1;
|
||||
if (timeSet > ts)
|
||||
{
|
||||
ts = timeSet;
|
||||
}
|
||||
|
||||
// prefix variables with 'c' (cloud)
|
||||
caseFile
|
||||
<< ensightType.c_str()
|
||||
<< " per measured node: " << ts << " "
|
||||
<< setw(15)
|
||||
<< ("c" + Foam::name(cloudNo) + fieldName).c_str()
|
||||
<< " "
|
||||
<< (dirName/fieldName).c_str()
|
||||
<< nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
caseFile
|
||||
<< ensightType.c_str()
|
||||
<< " per element: "
|
||||
<< setw(15) << fieldName
|
||||
<< " "
|
||||
<< (dirName/fieldName).c_str()
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::ensightParticlePositions
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const fileName& dataDir,
|
||||
const fileName& subDir,
|
||||
const word& cloudName,
|
||||
IOstream::streamFormat format
|
||||
)
|
||||
{
|
||||
Cloud<passiveParticle> parcels(mesh, cloudName, false);
|
||||
|
||||
fileName cloudDir = subDir/cloud::prefix/cloudName;
|
||||
fileName postFileName = cloudDir/"positions";
|
||||
|
||||
// the ITER/lagrangian subdirectory must exist
|
||||
mkDir(dataDir/cloudDir);
|
||||
ensightFile os(dataDir/postFileName, format);
|
||||
|
||||
// tag binary format (just like geometry files)
|
||||
os.writeBinaryHeader();
|
||||
os.write(postFileName);
|
||||
os.newline();
|
||||
os.write("particle coordinates");
|
||||
os.newline();
|
||||
os.write(parcels.size(), 8); // unusual width
|
||||
os.newline();
|
||||
|
||||
// binary write is Ensight6 - first ids, then positions
|
||||
if (format == IOstream::BINARY)
|
||||
{
|
||||
forAll(parcels, i)
|
||||
{
|
||||
os.write(i+1);
|
||||
}
|
||||
|
||||
forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
|
||||
{
|
||||
const vector& p = elmnt().position();
|
||||
|
||||
os.write(p.x());
|
||||
os.write(p.y());
|
||||
os.write(p.z());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
label nParcels = 0;
|
||||
|
||||
forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
|
||||
{
|
||||
const vector& p = elmnt().position();
|
||||
|
||||
os.write(++nParcels, 8); // unusual width
|
||||
os.write(p.x());
|
||||
os.write(p.y());
|
||||
os.write(p.z());
|
||||
os.newline();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::ensightLagrangianField
|
||||
(
|
||||
const IOobject& fieldObject,
|
||||
const fileName& dataDir,
|
||||
const fileName& subDir,
|
||||
const word& cloudName,
|
||||
IOstream::streamFormat format
|
||||
)
|
||||
{
|
||||
Info<< " " << fieldObject.name() << flush;
|
||||
|
||||
fileName cloudDir = subDir/cloud::prefix/cloudName;
|
||||
fileName postFileName = cloudDir/fieldObject.name();
|
||||
|
||||
string title =
|
||||
postFileName + " with " + pTraits<Type>::typeName + " values";
|
||||
|
||||
ensightFile os(dataDir/postFileName, format);
|
||||
os.write(title);
|
||||
os.newline();
|
||||
|
||||
IOField<Type> field(fieldObject);
|
||||
|
||||
// 6 values per line
|
||||
label count = 0;
|
||||
|
||||
forAll(field, i)
|
||||
{
|
||||
Type val = field[i];
|
||||
|
||||
if (mag(val) < 1.0e-90)
|
||||
{
|
||||
val = pTraits<Type>::zero;
|
||||
}
|
||||
|
||||
for (direction cmpt=0; cmpt < pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
os.write( component(val, cmpt) );
|
||||
}
|
||||
|
||||
count += pTraits<Type>::nComponents;
|
||||
|
||||
if (count % 6 == 0)
|
||||
{
|
||||
os.newline();
|
||||
}
|
||||
}
|
||||
|
||||
// add final newline if required
|
||||
if (count % 6)
|
||||
{
|
||||
os.newline();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//- write generalized field components
|
||||
template<class Type>
|
||||
void Foam::ensightVolField
|
||||
(
|
||||
const ensightParts& partsList,
|
||||
const IOobject& fieldObject,
|
||||
const fvMesh& mesh,
|
||||
const fileName& dataDir,
|
||||
const fileName& subDir,
|
||||
IOstream::streamFormat format
|
||||
)
|
||||
{
|
||||
Info<< " " << fieldObject.name() << flush;
|
||||
|
||||
fileName postFileName = subDir/fieldObject.name();
|
||||
|
||||
ensightFile os(dataDir/postFileName, format);
|
||||
os.write(postFileName);
|
||||
os.newline();
|
||||
|
||||
// ie, volField<Type>
|
||||
partsList.writeField
|
||||
(
|
||||
os,
|
||||
GeometricField<Type, fvPatchField, volMesh>
|
||||
(
|
||||
fieldObject,
|
||||
mesh
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,102 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Description
|
||||
Miscellaneous collection of functions and template related to Ensight data
|
||||
|
||||
SourceFiles
|
||||
ensightOutputFunctions.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ensightOutputFunctions_H
|
||||
#define ensightOutputFunctions_H
|
||||
|
||||
#include "ensightFile.H"
|
||||
#include "Cloud.H"
|
||||
#include "polyMesh.H"
|
||||
#include "IOobject.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void ensightCaseEntry
|
||||
(
|
||||
OFstream& caseFile,
|
||||
const string& ensightType,
|
||||
const word& fieldName,
|
||||
const fileName& dataMask,
|
||||
const fileName& local=fileName::null,
|
||||
const label cloudNo=-1,
|
||||
const label timeSet=1
|
||||
);
|
||||
|
||||
|
||||
void ensightParticlePositions
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const fileName& dataDir,
|
||||
const fileName& subDir,
|
||||
const word& cloudName,
|
||||
IOstream::streamFormat format
|
||||
);
|
||||
|
||||
|
||||
//- write lagrangian parcels
|
||||
template<class Type>
|
||||
void ensightLagrangianField
|
||||
(
|
||||
const IOobject& fieldObject,
|
||||
const fileName& dataDir,
|
||||
const fileName& subDir,
|
||||
const word& cloudName,
|
||||
IOstream::streamFormat format
|
||||
);
|
||||
|
||||
//- write generalized field components
|
||||
template<class Type>
|
||||
void ensightVolField
|
||||
(
|
||||
const ensightParts& partsList,
|
||||
const IOobject& fieldObject,
|
||||
const fvMesh& mesh,
|
||||
const fileName& dataDir,
|
||||
const fileName& subDir,
|
||||
IOstream::streamFormat format
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // namespace Foam
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "ensightOutputFunctions.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,105 @@
|
||||
// check the final time directory for the following:
|
||||
|
||||
// 1. volume fields
|
||||
HashTable<word> volumeFields;
|
||||
|
||||
// 2. the fields for each cloud:
|
||||
HashTable< HashTable<word> > cloudFields;
|
||||
|
||||
if (timeDirs.size())
|
||||
{
|
||||
IOobjectList objs(mesh, timeDirs.last().name());
|
||||
|
||||
forAllConstIter(IOobjectList, objs, fieldIter)
|
||||
{
|
||||
const IOobject& obj = *fieldIter();
|
||||
const word& fieldName = obj.name();
|
||||
const word& fieldType = obj.headerClassName();
|
||||
|
||||
if (fieldName.size() > 2 && fieldName(fieldName.size()-2, 2) == "_0")
|
||||
{
|
||||
// ignore _0 fields
|
||||
}
|
||||
else if (volFieldTypes.found(fieldType))
|
||||
{
|
||||
// simply ignore types that we don't handle
|
||||
volumeFields.insert(fieldName, fieldType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// now check for lagrangian/<cloudName>
|
||||
//
|
||||
fileNameList cloudDirs = readDir
|
||||
(
|
||||
runTime.path()
|
||||
/ timeDirs.last().name()
|
||||
/ regionPrefix
|
||||
/ cloud::prefix,
|
||||
fileName::DIRECTORY
|
||||
);
|
||||
|
||||
forAll(cloudDirs, cloudI)
|
||||
{
|
||||
const word& cloudName = cloudDirs[cloudI];
|
||||
|
||||
// Create a new hash table for each cloud
|
||||
cloudFields.insert(cloudName, HashTable<word>());
|
||||
|
||||
// Identify the new cloud within the hash table
|
||||
HashTable<HashTable<word> >::iterator cloudIter =
|
||||
cloudFields.find(cloudName);
|
||||
|
||||
IOobjectList objs
|
||||
(
|
||||
mesh,
|
||||
timeDirs.last().name(),
|
||||
cloud::prefix/cloudName
|
||||
);
|
||||
|
||||
bool hasPositions = false;
|
||||
forAllConstIter(IOobjectList, objs, fieldIter)
|
||||
{
|
||||
const IOobject obj = *fieldIter();
|
||||
const word& fieldName = obj.name();
|
||||
const word& fieldType = obj.headerClassName();
|
||||
|
||||
if (fieldName == "positions")
|
||||
{
|
||||
hasPositions = true;
|
||||
}
|
||||
else if (cloudFieldTypes.found(fieldType))
|
||||
{
|
||||
// simply ignore types that we don't handle
|
||||
cloudIter().insert(fieldName, fieldType);
|
||||
}
|
||||
}
|
||||
|
||||
// drop this cloud if it has no positions or is otherwise empty
|
||||
if (!hasPositions || cloudIter().empty())
|
||||
{
|
||||
Info<< "removing cloud " << cloudName << endl;
|
||||
cloudFields.erase(cloudIter);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// verify that the variable is present for all times
|
||||
//
|
||||
for (label i=0; volumeFields.size() && i < timeDirs.size(); ++i)
|
||||
{
|
||||
IOobjectList objs(mesh, timeDirs[i].name());
|
||||
|
||||
forAllIter(HashTable<word>, volumeFields, fieldIter)
|
||||
{
|
||||
const word& fieldName = fieldIter.key();
|
||||
|
||||
if (!objs.found(fieldName))
|
||||
{
|
||||
volumeFields.erase(fieldIter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,471 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Application
|
||||
foamToEnsightParts
|
||||
|
||||
Description
|
||||
Translates OpenFOAM data to Ensight format.
|
||||
An Ensight part is created for each cellZone and patch.
|
||||
|
||||
Usage
|
||||
- foamToEnsightParts [OPTION] \n
|
||||
Translates OpenFOAM data to Ensight format
|
||||
|
||||
\param -ascii \n
|
||||
Write Ensight data in ASCII format instead of "C Binary"
|
||||
|
||||
\parm -name \<subdir\>\n
|
||||
define sub-directory name to use for Ensight data (default: "Ensight")
|
||||
|
||||
\param -noZero \n
|
||||
Exclude the often incomplete initial conditions.
|
||||
|
||||
\param -index \<start\>\n
|
||||
Ignore the time index contained in the time file and use a
|
||||
simple indexing when creating the \c Ensight/data/######## files.
|
||||
|
||||
\param -noMesh \n
|
||||
Suppress writing the geometry. Can be useful for converting partial
|
||||
results for a static geometry.
|
||||
|
||||
\param -width \<n\>\n
|
||||
width of Ensight data subdir
|
||||
|
||||
Note
|
||||
- no parallel data.
|
||||
- writes to \a Ensight directory to avoid collisions with foamToEnsight.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
|
||||
#include "volFields.H"
|
||||
#include "OFstream.H"
|
||||
#include "IOmanip.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "scalarIOField.H"
|
||||
#include "tensorIOField.H"
|
||||
|
||||
#include "ensightParts.H"
|
||||
#include "ensightOutputFunctions.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// enable -constant
|
||||
// probably don't need -zeroTime though, since the fields are vetted
|
||||
// afterwards anyhow
|
||||
timeSelector::addOptions(true, false);
|
||||
argList::noParallel();
|
||||
argList::addBoolOption
|
||||
(
|
||||
"ascii",
|
||||
"write in ASCII format instead of 'C Binary'"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"index",
|
||||
"start",
|
||||
"ignore the time index contained in the uniform/time file "
|
||||
"and use simple indexing when creating the files"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"noMesh",
|
||||
"suppress writing the geometry. "
|
||||
"Can be useful for converting partial results for a static geometry"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"name",
|
||||
"subdir",
|
||||
"define sub-directory name to use for Ensight data "
|
||||
"(default: \"Ensight\")"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"width",
|
||||
"n",
|
||||
"width of Ensight data subdir"
|
||||
);
|
||||
|
||||
// the volume field types that we handle
|
||||
wordHashSet volFieldTypes;
|
||||
volFieldTypes.insert(volScalarField::typeName);
|
||||
volFieldTypes.insert(volVectorField::typeName);
|
||||
volFieldTypes.insert(volSphericalTensorField::typeName);
|
||||
volFieldTypes.insert(volSymmTensorField::typeName);
|
||||
volFieldTypes.insert(volTensorField::typeName);
|
||||
|
||||
// the lagrangian field types that we handle
|
||||
wordHashSet cloudFieldTypes;
|
||||
cloudFieldTypes.insert(scalarIOField::typeName);
|
||||
cloudFieldTypes.insert(vectorIOField::typeName);
|
||||
cloudFieldTypes.insert(tensorIOField::typeName);
|
||||
|
||||
const char* geometryName = "geometry";
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
// get times list
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
|
||||
// default to binary output, unless otherwise specified
|
||||
IOstream::streamFormat format = IOstream::BINARY;
|
||||
if (args.optionFound("ascii"))
|
||||
{
|
||||
format = IOstream::ASCII;
|
||||
}
|
||||
|
||||
// control for renumbering iterations
|
||||
label indexingNumber = 0;
|
||||
bool optIndex = args.optionReadIfPresent("index", indexingNumber);
|
||||
|
||||
// always write the geometry, unless the -noMesh option is specified
|
||||
bool optNoMesh = args.optionFound("noMesh");
|
||||
|
||||
// adjust output width
|
||||
if (args.optionFound("width"))
|
||||
{
|
||||
ensightFile::subDirWidth(args.optionRead<label>("width"));
|
||||
}
|
||||
|
||||
// define sub-directory name to use for Ensight data
|
||||
fileName ensightDir = "Ensight";
|
||||
args.optionReadIfPresent("name", ensightDir);
|
||||
|
||||
if (!ensightDir.isAbsolute())
|
||||
{
|
||||
ensightDir = args.rootPath()/args.globalCaseName()/ensightDir;
|
||||
}
|
||||
|
||||
fileName dataDir = ensightDir/"data";
|
||||
fileName caseFileName = "Ensight.case";
|
||||
fileName dataMask = fileName("data")/ensightFile::mask();
|
||||
|
||||
// Ensight and Ensight/data directories must exist
|
||||
// do not remove old data - we might wish to convert new results
|
||||
// or a particular time interval
|
||||
if (isDir(ensightDir))
|
||||
{
|
||||
Info<<"Warning: re-using existing directory" << nl
|
||||
<< " " << ensightDir << endl;
|
||||
}
|
||||
mkDir(ensightDir);
|
||||
mkDir(dataDir);
|
||||
|
||||
#include "createNamedMesh.H"
|
||||
|
||||
// Mesh instance (region0 gets filtered out)
|
||||
fileName regionPrefix;
|
||||
|
||||
if (regionName != polyMesh::defaultRegion)
|
||||
{
|
||||
regionPrefix = regionName;
|
||||
}
|
||||
|
||||
// Construct the list of ensight parts for the entire mesh
|
||||
ensightParts partsList(mesh);
|
||||
|
||||
// write summary information
|
||||
{
|
||||
OFstream partsInfoFile(ensightDir/"partsInfo");
|
||||
|
||||
partsInfoFile
|
||||
<< "// summary of ensight parts" << nl << nl;
|
||||
partsList.writeSummary(partsInfoFile);
|
||||
}
|
||||
|
||||
#include "checkHasMovingMesh.H"
|
||||
#include "findFields.H"
|
||||
|
||||
if (hasMovingMesh && optNoMesh)
|
||||
{
|
||||
Info<< "mesh is moving: ignoring '-noMesh' option" << endl;
|
||||
optNoMesh = false;
|
||||
}
|
||||
|
||||
|
||||
// map times used
|
||||
Map<scalar> timeIndices;
|
||||
|
||||
// Track the time indices used by the volume fields
|
||||
DynamicList<label> fieldTimesUsed;
|
||||
|
||||
// Track the time indices used by each cloud
|
||||
HashTable<DynamicList<label> > cloudTimesUsed;
|
||||
|
||||
// Create a new DynamicList for each cloud
|
||||
forAllConstIter(HashTable<HashTable<word> >, cloudFields, cloudIter)
|
||||
{
|
||||
cloudTimesUsed.insert(cloudIter.key(), DynamicList<label>());
|
||||
}
|
||||
|
||||
|
||||
forAll(timeDirs, timeI)
|
||||
{
|
||||
runTime.setTime(timeDirs[timeI], timeI);
|
||||
|
||||
#include "getTimeIndex.H"
|
||||
|
||||
// remember the time index
|
||||
fieldTimesUsed.append(timeIndex);
|
||||
|
||||
// the data/ITER subdirectory must exist
|
||||
fileName subDir = ensightFile::subDir(timeIndex);
|
||||
mkDir(dataDir/subDir);
|
||||
|
||||
// place a timestamp in the directory for future reference
|
||||
{
|
||||
OFstream timeStamp(dataDir/subDir/"time");
|
||||
timeStamp
|
||||
<< "# timestep time" << nl
|
||||
<< subDir.c_str() << " " << runTime.timeName() << nl;
|
||||
}
|
||||
|
||||
#include "moveMesh.H"
|
||||
|
||||
if (timeI == 0 || mesh.moving())
|
||||
{
|
||||
if (mesh.moving())
|
||||
{
|
||||
partsList.recalculate(mesh);
|
||||
}
|
||||
|
||||
if (!optNoMesh)
|
||||
{
|
||||
fileName geomDir;
|
||||
if (hasMovingMesh)
|
||||
{
|
||||
geomDir = dataDir/subDir;
|
||||
}
|
||||
|
||||
ensightGeoFile geoFile(ensightDir/geomDir/geometryName, format);
|
||||
partsList.writeGeometry(geoFile);
|
||||
Info<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "write volume field (" << flush;
|
||||
|
||||
forAllConstIter(HashTable<word>, volumeFields, fieldIter)
|
||||
{
|
||||
const word& fieldName = fieldIter.key();
|
||||
const word& fieldType = fieldIter();
|
||||
|
||||
IOobject fieldObject
|
||||
(
|
||||
fieldName,
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
if (fieldType == volScalarField::typeName)
|
||||
{
|
||||
ensightVolField<scalar>
|
||||
(
|
||||
partsList,
|
||||
fieldObject,
|
||||
mesh,
|
||||
dataDir,
|
||||
subDir,
|
||||
format
|
||||
);
|
||||
|
||||
}
|
||||
else if (fieldType == volVectorField::typeName)
|
||||
{
|
||||
ensightVolField<vector>
|
||||
(
|
||||
partsList,
|
||||
fieldObject,
|
||||
mesh,
|
||||
dataDir,
|
||||
subDir,
|
||||
format
|
||||
);
|
||||
|
||||
}
|
||||
else if (fieldType == volSphericalTensorField::typeName)
|
||||
{
|
||||
ensightVolField<sphericalTensor>
|
||||
(
|
||||
partsList,
|
||||
fieldObject,
|
||||
mesh,
|
||||
dataDir,
|
||||
subDir,
|
||||
format
|
||||
);
|
||||
|
||||
}
|
||||
else if (fieldType == volSymmTensorField::typeName)
|
||||
{
|
||||
ensightVolField<symmTensor>
|
||||
(
|
||||
partsList,
|
||||
fieldObject,
|
||||
mesh,
|
||||
dataDir,
|
||||
subDir,
|
||||
format
|
||||
);
|
||||
}
|
||||
else if (fieldType == volTensorField::typeName)
|
||||
{
|
||||
ensightVolField<tensor>
|
||||
(
|
||||
partsList,
|
||||
fieldObject,
|
||||
mesh,
|
||||
dataDir,
|
||||
subDir,
|
||||
format
|
||||
);
|
||||
}
|
||||
}
|
||||
Info<< " )" << endl;
|
||||
|
||||
// check for clouds
|
||||
forAllConstIter(HashTable<HashTable<word> >, cloudFields, cloudIter)
|
||||
{
|
||||
const word& cloudName = cloudIter.key();
|
||||
|
||||
if
|
||||
(
|
||||
!isDir
|
||||
(
|
||||
runTime.timePath()/regionPrefix/
|
||||
cloud::prefix/cloudName
|
||||
)
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IOobjectList cloudObjs
|
||||
(
|
||||
mesh,
|
||||
runTime.timeName(),
|
||||
cloud::prefix/cloudName
|
||||
);
|
||||
|
||||
// check that the positions field is present for this time
|
||||
IOobject* positionPtr = cloudObjs.lookup(word("positions"));
|
||||
if (positionPtr != NULL)
|
||||
{
|
||||
ensightParticlePositions
|
||||
(
|
||||
mesh,
|
||||
dataDir,
|
||||
subDir,
|
||||
cloudName,
|
||||
format
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Info<< "write " << cloudName << " (" << flush;
|
||||
|
||||
forAllConstIter(HashTable<word>, cloudIter(), fieldIter)
|
||||
{
|
||||
const word& fieldName = fieldIter.key();
|
||||
const word& fieldType = fieldIter();
|
||||
|
||||
IOobject *fieldObject = cloudObjs.lookup(fieldName);
|
||||
|
||||
if (!fieldObject)
|
||||
{
|
||||
Info<< "missing "
|
||||
<< runTime.timeName()/cloud::prefix/cloudName
|
||||
/ fieldName
|
||||
<< endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fieldType == scalarIOField::typeName)
|
||||
{
|
||||
ensightLagrangianField<scalar>
|
||||
(
|
||||
*fieldObject,
|
||||
dataDir,
|
||||
subDir,
|
||||
cloudName,
|
||||
format
|
||||
);
|
||||
|
||||
}
|
||||
else if (fieldType == vectorIOField::typeName)
|
||||
{
|
||||
ensightLagrangianField<vector>
|
||||
(
|
||||
*fieldObject,
|
||||
dataDir,
|
||||
subDir,
|
||||
cloudName,
|
||||
format
|
||||
);
|
||||
|
||||
}
|
||||
else if (fieldType == tensorIOField::typeName)
|
||||
{
|
||||
ensightLagrangianField<tensor>
|
||||
(
|
||||
*fieldObject,
|
||||
dataDir,
|
||||
subDir,
|
||||
cloudName,
|
||||
format
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Info<< " )" << endl;
|
||||
|
||||
// remember the time index
|
||||
cloudTimesUsed[cloudName].append(timeIndex);
|
||||
}
|
||||
}
|
||||
|
||||
#include "ensightOutputCase.H"
|
||||
|
||||
Info<< "\nEnd\n"<< endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,43 @@
|
||||
// Read time index from */uniform/time, but treat 0 and constant specially
|
||||
// or simply increment from the '-index' option if it was supplied
|
||||
|
||||
label timeIndex = 0;
|
||||
|
||||
if (optIndex)
|
||||
{
|
||||
timeIndex = indexingNumber++;
|
||||
}
|
||||
else if
|
||||
(
|
||||
runTime.timeName() != runTime.constant()
|
||||
&& runTime.timeName() != "0"
|
||||
)
|
||||
{
|
||||
IOobject io
|
||||
(
|
||||
"time",
|
||||
runTime.timeName(),
|
||||
"uniform",
|
||||
runTime,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
if (io.headerOk())
|
||||
{
|
||||
io.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
|
||||
IOdictionary timeObject(io);
|
||||
|
||||
timeObject.lookup("index") >> timeIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "skip ... missing entry " << io.objectPath() << endl;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
timeIndices.insert(timeIndex, timeDirs[timeI].value());
|
||||
Info<< "\nTime [" << timeIndex << "] = " << runTime.timeName() << nl;
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
{
|
||||
IOobject io
|
||||
(
|
||||
"points",
|
||||
runTime.timeName(),
|
||||
polyMesh::meshSubDir,
|
||||
mesh
|
||||
);
|
||||
|
||||
if (io.headerOk())
|
||||
{
|
||||
// Read new points
|
||||
io.readOpt() = IOobject::MUST_READ;
|
||||
mesh.movePoints(pointIOField(io));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
foamToGMV.C
|
||||
itoa.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/foamToGMV
|
||||
@ -0,0 +1,13 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools \
|
||||
-lgenericPatchFields \
|
||||
-llagrangian
|
||||
@ -0,0 +1,100 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Application
|
||||
foamToGMV
|
||||
|
||||
Description
|
||||
Translates foam output to GMV readable files.
|
||||
|
||||
A free post-processor with available binaries from
|
||||
http://www-xdiv.lanl.gov/XCM/gmv/
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "OFstream.H"
|
||||
#include "instantList.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "itoa.H"
|
||||
#include "Cloud.H"
|
||||
#include "passiveParticle.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const label nTypes = 4;
|
||||
const word fieldTypes[] =
|
||||
{
|
||||
"volScalarField",
|
||||
"volVectorField",
|
||||
"surfaceScalarField",
|
||||
cloud::prefix
|
||||
};
|
||||
|
||||
# include "setRootCase.H"
|
||||
|
||||
# include "createTime.H"
|
||||
# include "createMesh.H"
|
||||
|
||||
# include "readConversionProperties.H"
|
||||
|
||||
// get the available time-steps
|
||||
instantList TimeList = runTime.times();
|
||||
Info<< TimeList << endl;
|
||||
label nTimes = TimeList.size();
|
||||
|
||||
for (label n=1; n < nTimes; n++)
|
||||
{
|
||||
if (TimeList[n].value() > startTime)
|
||||
{
|
||||
Info<< "Time = " << TimeList[n].value() << nl;
|
||||
|
||||
// Set Time
|
||||
runTime.setTime(TimeList[n], n);
|
||||
word CurTime = runTime.timeName();
|
||||
|
||||
IOobjectList objects(mesh, runTime.timeName());
|
||||
|
||||
# include "moveMesh.H"
|
||||
|
||||
// set the filename of the GMV file
|
||||
fileName gmvFileName = "plotGMV." + itoa(n);
|
||||
OFstream gmvFile(args.rootPath()/args.caseName()/gmvFileName);
|
||||
|
||||
# include "gmvOutputHeader.H"
|
||||
# include "gmvOutput.H"
|
||||
# include "gmvOutputTail.H"
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -0,0 +1,94 @@
|
||||
for (label i=0; i < nTypes; i++)
|
||||
{
|
||||
wordList fieldNames = objects.names(fieldTypes[i]);
|
||||
|
||||
if (fieldTypes[i] == "volScalarField")
|
||||
{
|
||||
gmvFile << "variable" << nl;
|
||||
}
|
||||
|
||||
forAll(fieldNames, j)
|
||||
{
|
||||
const word& fieldName = fieldNames[j];
|
||||
|
||||
IOobject fieldObject
|
||||
(
|
||||
fieldName,
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
if (fieldTypes[i] == "volScalarField")
|
||||
{
|
||||
volScalarField fld(fieldObject, mesh);
|
||||
gmvFile << fieldName << " 0" << nl;
|
||||
for (label indx=0;indx<mesh.nCells();indx++)
|
||||
{
|
||||
gmvFile << fld[indx] << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
}
|
||||
|
||||
if (fieldTypes[i] == "volVectorField")
|
||||
{
|
||||
if (fieldName == vComp)
|
||||
{
|
||||
volVectorField fld(fieldObject, mesh);
|
||||
gmvFile << "velocity 0" << nl;
|
||||
for (label indx=0;indx<mesh.nCells();indx++)
|
||||
{
|
||||
gmvFile << fld[indx].x() << " ";
|
||||
}
|
||||
for (label indx=0;indx<mesh.nCells();indx++)
|
||||
{
|
||||
gmvFile << fld[indx].y() << " ";
|
||||
}
|
||||
for (label indx=0;indx<mesh.nCells();indx++)
|
||||
{
|
||||
gmvFile << fld[indx].z() << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldTypes[i] == "surfaceScalarField")
|
||||
{
|
||||
// ...
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (fieldTypes[i] == cloud::prefix)
|
||||
{
|
||||
IOobject lagrangianHeader
|
||||
(
|
||||
"positions",
|
||||
runTime.timeName(),
|
||||
cloud::prefix,
|
||||
mesh,
|
||||
IOobject::NO_READ
|
||||
);
|
||||
|
||||
if (lagrangianHeader.headerOk())
|
||||
{
|
||||
Cloud<passiveParticle> particles(mesh);
|
||||
|
||||
IOobjectList objects(mesh, runTime.timeName(), cloud::prefix);
|
||||
|
||||
wordList lagrangianScalarNames = objects.names("scalarField");
|
||||
wordList lagrangianVectorNames = objects.names("vectorField");
|
||||
|
||||
if (particles.size())
|
||||
{
|
||||
# include "gmvOutputLagrangian.H"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldTypes[i] == "volScalarField")
|
||||
{
|
||||
gmvFile << "endvars" << nl;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
const pointField& points = mesh.points();
|
||||
label nPoints = points.size();
|
||||
const cellShapeList& cells = mesh.cellShapes();
|
||||
|
||||
gmvFile << "gmvinput " << format << nl;
|
||||
gmvFile << "nodes " << nPoints << nl;
|
||||
for (label indx=0;indx<nPoints;indx++)
|
||||
{
|
||||
gmvFile << points[indx].x() << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
for (label indx=0;indx<nPoints;indx++)
|
||||
{
|
||||
gmvFile << points[indx].y() << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
for (label indx=0;indx<nPoints;indx++)
|
||||
{
|
||||
gmvFile << points[indx].z() << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
gmvFile << "cells " << cells.size() << nl;
|
||||
forAll(cells, indx)
|
||||
{
|
||||
label nNodes = cells[indx].size();
|
||||
if (nNodes == 8)
|
||||
{
|
||||
gmvFile << "hex " << 8 << " ";
|
||||
for (label ip=0; ip<nNodes; ip++)
|
||||
{
|
||||
gmvFile << cells[indx][ip] + 1 << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
}
|
||||
else if (nNodes == 4)
|
||||
{
|
||||
gmvFile << "tet " << 4 << " ";
|
||||
for (label ip=0; ip<nNodes; ip++)
|
||||
{
|
||||
gmvFile << cells[indx][ip] + 1 << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
}
|
||||
else if (nNodes == 6)
|
||||
{
|
||||
gmvFile << "prism " << 6 << " ";
|
||||
for (label ip=0; ip<nNodes; ip++)
|
||||
{
|
||||
gmvFile << cells[indx][ip] + 1 << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
gmvFile << "tracers " << particles.size() << nl;
|
||||
forAllConstIter(Cloud<passiveParticle>, particles, iter)
|
||||
{
|
||||
gmvFile << iter().position().x() << ' ';
|
||||
}
|
||||
gmvFile << nl;
|
||||
|
||||
forAllConstIter(Cloud<passiveParticle>, particles, iter)
|
||||
{
|
||||
gmvFile << iter().position().y() << ' ';
|
||||
}
|
||||
gmvFile << nl;
|
||||
|
||||
forAllConstIter(Cloud<passiveParticle>, particles, iter)
|
||||
{
|
||||
gmvFile << iter().position().z() << ' ';
|
||||
}
|
||||
gmvFile << nl;
|
||||
|
||||
forAll(lagrangianScalarNames, i)
|
||||
{
|
||||
const word& name = lagrangianScalarNames[i];
|
||||
|
||||
IOField<scalar> fld
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
runTime.timeName(),
|
||||
cloud::prefix,
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
if (fld.size())
|
||||
{
|
||||
gmvFile << name << nl;
|
||||
|
||||
forAll(fld, n)
|
||||
{
|
||||
gmvFile << fld[n] << token::SPACE;
|
||||
}
|
||||
gmvFile << nl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
forAll(lagrangianVectorNames, i)
|
||||
{
|
||||
const word& name = lagrangianVectorNames[i];
|
||||
|
||||
IOField<vector> fld
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
runTime.timeName(),
|
||||
cloud::prefix,
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
if (fld.size())
|
||||
{
|
||||
gmvFile << name + "x" << nl;
|
||||
|
||||
forAll(fld, n)
|
||||
{
|
||||
gmvFile << fld[n].x() << token::SPACE;
|
||||
}
|
||||
gmvFile << nl;
|
||||
|
||||
gmvFile << name + "y" << nl;
|
||||
|
||||
forAll(fld, n)
|
||||
{
|
||||
gmvFile << fld[n].y() << token::SPACE;
|
||||
}
|
||||
gmvFile << nl;
|
||||
|
||||
gmvFile << name + "z" << nl;
|
||||
|
||||
forAll(fld, n)
|
||||
{
|
||||
gmvFile << fld[n].z() << token::SPACE;
|
||||
}
|
||||
gmvFile << nl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
gmvFile << "endtrace"<< nl;
|
||||
@ -0,0 +1,48 @@
|
||||
gmvFile << "tracers " << particles.size() << nl;
|
||||
forAllConstIter(discretePhase, particles, iter)
|
||||
{
|
||||
gmvFile << iter().position().x() << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
|
||||
forAllConstIter(discretePhase, particles, iter)
|
||||
{
|
||||
gmvFile << iter().position().y() << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
|
||||
forAllConstIter(discretePhase, particles, iter)
|
||||
{
|
||||
gmvFile << iter().position().z() << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
|
||||
gmvFile << "U" << nl;
|
||||
forAllConstIter(discretePhase, particles, iter)
|
||||
{
|
||||
gmvFile << iter().velocity().x() << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
|
||||
gmvFile << "V" << nl;
|
||||
forAllConstIter(discretePhase, particles, iter)
|
||||
{
|
||||
gmvFile << iter().velocity().y() << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
|
||||
gmvFile << "W" << nl;
|
||||
forAllConstIter(discretePhase, particles, iter)
|
||||
{
|
||||
{
|
||||
gmvFile << iter().velocity().z() << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
|
||||
gmvFile << "Diam" << nl;
|
||||
forAllConstIter(discretePhase, particles, iter)
|
||||
{
|
||||
gmvFile << iter().d() << " ";
|
||||
}
|
||||
|
||||
gmvFile << "endtrace"<< nl;
|
||||
@ -0,0 +1,50 @@
|
||||
gmvFile << "tracers " << particles.size() << nl;
|
||||
forAllConstIter(Cloud<passiveParticle>, particles, iter)
|
||||
{
|
||||
gmvFile << iter().position().x() << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
|
||||
forAllConstIter(Cloud<passiveParticle>, particles, iter)
|
||||
{
|
||||
gmvFile << iter().position().y() << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
|
||||
forAllConstIter(Cloud<passiveParticle>, particles, iter)
|
||||
{
|
||||
gmvFile << iter().position().z() << " ";
|
||||
}
|
||||
gmvFile << nl;
|
||||
|
||||
forAll(lagrangianScalarNames, i)
|
||||
{
|
||||
word name = lagrangianScalarNames[i];
|
||||
|
||||
IOField<scalar> s
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
runTime.timeName(),
|
||||
cloud::prefix,
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
if (s.size())
|
||||
{
|
||||
gmvFile << name << nl;
|
||||
|
||||
forAll(s, n)
|
||||
{
|
||||
gmvFile << s[n] << token::SPACE;
|
||||
}
|
||||
gmvFile << nl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gmvFile << "endtrace"<< nl;
|
||||
@ -0,0 +1,3 @@
|
||||
gmvFile
|
||||
<< "probtime " << runTime.timeName() << nl
|
||||
<< "endgmv" << nl;
|
||||
@ -0,0 +1,61 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "itoa.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
word itoa(const label n)
|
||||
{
|
||||
const label offset = '0';
|
||||
const label length = 3;
|
||||
|
||||
char val[length + 1];
|
||||
|
||||
label leftOfN = n;
|
||||
|
||||
for (label i=0; i<length; i++)
|
||||
{
|
||||
label j = label(leftOfN/pow(10, length-i-1));
|
||||
leftOfN -= j*pow(10,length-i-1);
|
||||
val[i] = offset + j;
|
||||
}
|
||||
|
||||
val[length] = 0;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,44 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "word.H"
|
||||
#include "label.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
word itoa(const label n);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,27 @@
|
||||
IOobject ioPoints
|
||||
(
|
||||
"points",
|
||||
runTime.timeName(),
|
||||
mesh.name(),
|
||||
mesh
|
||||
);
|
||||
|
||||
if (ioPoints.headerOk())
|
||||
{
|
||||
Info<< "new points available" << endl;
|
||||
// Reading new points
|
||||
pointIOField newPoints
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"points",
|
||||
runTime.timeName(),
|
||||
mesh.name(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
mesh.movePoints(newPoints);
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
IOdictionary conversionProperties
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"conversionProperties",
|
||||
runTime.constant(),
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
scalar startTime
|
||||
(
|
||||
readScalar(conversionProperties.lookup("startTime"))
|
||||
);
|
||||
|
||||
word vComp
|
||||
(
|
||||
conversionProperties.lookup("vector")
|
||||
);
|
||||
|
||||
word format
|
||||
(
|
||||
conversionProperties.lookup("format")
|
||||
);
|
||||
|
||||
if ((format != "ascii") && (format != "ieeei4r8"))
|
||||
{
|
||||
FatalError
|
||||
<< "format type: " << format << " unknown."
|
||||
<< " Valid options are: ascii ieeei4r8"
|
||||
<< abort(FatalError);
|
||||
|
||||
}
|
||||
|
||||
word cells
|
||||
(
|
||||
conversionProperties.lookup("cells")
|
||||
);
|
||||
|
||||
if
|
||||
(
|
||||
(cells != "hex")
|
||||
)
|
||||
{
|
||||
FatalError
|
||||
<< "cells type: " << cells << " unknown."
|
||||
<< abort(FatalError);
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # run from this directory
|
||||
|
||||
if [ ! -d ${WM_THIRD_PARTY_DIR}/tecio ]
|
||||
then
|
||||
echo "Did not find tecio in ${WM_THIRD_PARTY_DIR}. Not building foamToTecplot360."
|
||||
else
|
||||
wmake
|
||||
fi
|
||||
|
||||
# ----------------------------------------------------------------- end-of-file
|
||||
@ -0,0 +1,5 @@
|
||||
tecplotWriter.C
|
||||
vtkMesh.C
|
||||
foamToTecplot360.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/foamToTecplot360
|
||||
@ -0,0 +1,13 @@
|
||||
EXE_INC = \
|
||||
-I$(WM_THIRD_PARTY_DIR)/tecio/tecsrc/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
|
||||
EXE_LIBS = \
|
||||
-llagrangian \
|
||||
-lfiniteVolume \
|
||||
-lgenericPatchFields \
|
||||
-lmeshTools \
|
||||
-L$(FOAM_EXT_LIBBIN) -ltecio
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,81 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "readFields.H"
|
||||
#include "IOobjectList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class GeoField>
|
||||
void readFields
|
||||
(
|
||||
const vtkMesh& vMesh,
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
const HashSet<word>& selectedFields,
|
||||
PtrList<GeoField>& fields
|
||||
)
|
||||
{
|
||||
// Search list of objects for volScalarFields
|
||||
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
|
||||
|
||||
// Construct the vol scalar fields
|
||||
label nFields = fields.size();
|
||||
fields.setSize(nFields + fieldObjects.size());
|
||||
|
||||
forAllIter(IOobjectList, fieldObjects, iter)
|
||||
{
|
||||
if (selectedFields.empty() || selectedFields.found(iter()->name()))
|
||||
{
|
||||
fields.set
|
||||
(
|
||||
nFields,
|
||||
vMesh.interpolate
|
||||
(
|
||||
GeoField
|
||||
(
|
||||
*iter(),
|
||||
mesh
|
||||
)
|
||||
)
|
||||
);
|
||||
nFields++;
|
||||
}
|
||||
}
|
||||
|
||||
fields.setSize(nFields);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,70 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InClass
|
||||
Foam::readFields
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
readFields.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef readFields_H
|
||||
#define readFields_H
|
||||
|
||||
#include "fvMesh.H"
|
||||
#include "PtrList.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Read the fields and optionally subset and put on the pointer list
|
||||
template<class GeoField>
|
||||
void readFields
|
||||
(
|
||||
const vtkMesh& vMesh,
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
const HashSet<word>& selectedFields,
|
||||
PtrList<GeoField>& fields
|
||||
);
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "readFields.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,515 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "tecplotWriter.H"
|
||||
#include "fvMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::tecplotWriter::tecplotWriter(const Time& runTime)
|
||||
:
|
||||
runTime_(runTime)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::tecplotWriter::writeInit
|
||||
(
|
||||
const word& name,
|
||||
const string& varNames,
|
||||
const fileName& fName,
|
||||
INTEGER4 tecplotFileType
|
||||
) const
|
||||
{
|
||||
Pout<< endl
|
||||
<< endl
|
||||
<< "Name:" << name
|
||||
<< " varNames:" << varNames
|
||||
<< " to file:" << fName
|
||||
<< " of type:" << tecplotFileType
|
||||
<< endl;
|
||||
|
||||
INTEGER4 IsDouble = 0; //float
|
||||
INTEGER4 Debug = 0; //nodebug
|
||||
if
|
||||
(
|
||||
!TECINI112
|
||||
(
|
||||
const_cast<char*>(name.c_str()), /* Data Set Title */
|
||||
const_cast<char*>(varNames.c_str()), /* Variable List */
|
||||
const_cast<char*>(fName.c_str()), /* File Name */
|
||||
const_cast<char*>(runTime_.path().c_str()), /* Scratch Directory */
|
||||
&tecplotFileType,
|
||||
&Debug,
|
||||
&IsDouble
|
||||
)
|
||||
)
|
||||
{
|
||||
// FatalErrorIn("tecplotWriter::writeInit(..) const")
|
||||
// << "Error in TECINI112." << exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::tecplotWriter::writePolyhedralZone
|
||||
(
|
||||
const word& zoneName,
|
||||
INTEGER4 strandID,
|
||||
const fvMesh& mesh,
|
||||
const List<INTEGER4>& varLocArray,
|
||||
INTEGER4 nFaceNodes
|
||||
) const
|
||||
{
|
||||
/* Call TECZNE112 */
|
||||
INTEGER4 NumNodes = mesh.nPoints(); /* number of unique nodes */
|
||||
INTEGER4 NumElems = mesh.nCells(); /* number of elements */
|
||||
INTEGER4 NumFaces = mesh.nFaces(); /* 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 = runTime_.value(); /* solution time */
|
||||
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
|
||||
*/
|
||||
Pout<< "zoneName:" << zoneName
|
||||
//<< " varLocArray:" << varLocArray
|
||||
<< " solTime:" << SolTime
|
||||
<< endl;
|
||||
|
||||
|
||||
|
||||
INTEGER4 *PassiveVarArray = NULL;
|
||||
INTEGER4 *VarShareArray = NULL;
|
||||
INTEGER4 ShrConn = 0;
|
||||
|
||||
INTEGER4 NumBConns = 0; /* No Boundary Connections */
|
||||
INTEGER4 NumBItems = 0; /* No Boundary Items */
|
||||
|
||||
INTEGER4 ZoneType = ZoneType_FEPolyhedron;
|
||||
|
||||
if
|
||||
(
|
||||
!TECZNE112
|
||||
(
|
||||
const_cast<char*>(zoneName.c_str()),
|
||||
&ZoneType,
|
||||
&NumNodes,
|
||||
&NumElems,
|
||||
&NumFaces,
|
||||
&ICellMax,
|
||||
&JCellMax,
|
||||
&KCellMax,
|
||||
&SolTime,
|
||||
&strandID,
|
||||
&ParentZone,
|
||||
&IsBlock,
|
||||
&NFConns,
|
||||
&FNMode,
|
||||
&nFaceNodes,
|
||||
&NumBConns,
|
||||
&NumBItems,
|
||||
PassiveVarArray,
|
||||
const_cast<INTEGER4*>(varLocArray.begin()),
|
||||
VarShareArray,
|
||||
&ShrConn
|
||||
)
|
||||
)
|
||||
{
|
||||
// FatalErrorIn("tecplotWriter::writePolyhedralZone(..) const")
|
||||
// << "Error in TECZNE112." << exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::tecplotWriter::writePolygonalZone
|
||||
(
|
||||
const word& zoneName,
|
||||
INTEGER4 strandID,
|
||||
const indirectPrimitivePatch& pp,
|
||||
const List<INTEGER4>& varLocArray
|
||||
) const
|
||||
{
|
||||
/* Call TECZNE112 */
|
||||
INTEGER4 NumNodes = pp.nPoints(); /* number of unique nodes */
|
||||
INTEGER4 NumElems = pp.size(); /* number of elements */
|
||||
INTEGER4 NumFaces = pp.nEdges(); /* 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 = runTime_.value(); /* solution time */
|
||||
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 NumFaceNodes = 2*pp.nEdges();
|
||||
|
||||
Pout<< "zoneName:" << zoneName
|
||||
<< " strandID:" << strandID
|
||||
//<< " varLocArray:" << varLocArray
|
||||
<< " solTime:" << SolTime
|
||||
<< endl;
|
||||
|
||||
|
||||
INTEGER4 *PassiveVarArray = NULL;
|
||||
INTEGER4 *VarShareArray = NULL;
|
||||
INTEGER4 ShrConn = 0;
|
||||
|
||||
INTEGER4 NumBConns = 0; /* No Boundary Connections */
|
||||
INTEGER4 NumBItems = 0; /* No Boundary Items */
|
||||
|
||||
INTEGER4 ZoneType = ZoneType_FEPolygon;
|
||||
|
||||
if
|
||||
(
|
||||
!TECZNE112
|
||||
(
|
||||
const_cast<char*>(zoneName.c_str()),
|
||||
&ZoneType,
|
||||
&NumNodes,
|
||||
&NumElems,
|
||||
&NumFaces,
|
||||
&ICellMax,
|
||||
&JCellMax,
|
||||
&KCellMax,
|
||||
&SolTime,
|
||||
&strandID,
|
||||
&ParentZone,
|
||||
&IsBlock,
|
||||
&NFConns,
|
||||
&FNMode,
|
||||
&NumFaceNodes,
|
||||
&NumBConns,
|
||||
&NumBItems,
|
||||
PassiveVarArray,
|
||||
const_cast<INTEGER4*>(varLocArray.begin()),
|
||||
VarShareArray,
|
||||
&ShrConn
|
||||
)
|
||||
)
|
||||
{
|
||||
// FatalErrorIn("tecplotWriter::writePolygonalZone(..) const")
|
||||
// << "Error in TECZNE112." << exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::tecplotWriter::writeOrderedZone
|
||||
(
|
||||
const word& zoneName,
|
||||
INTEGER4 strandID,
|
||||
const label n,
|
||||
const List<INTEGER4>& varLocArray
|
||||
) const
|
||||
{
|
||||
/* Call TECZNE112 */
|
||||
INTEGER4 IMax = n; /* number of unique nodes */
|
||||
INTEGER4 JMax = 1; /* number of elements */
|
||||
INTEGER4 KMax = 1; /* 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 = runTime_.value(); /* solution time */
|
||||
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 NumFaceNodes = 1;
|
||||
INTEGER4 NumBConns = 1; /* No Boundary Connections */
|
||||
INTEGER4 NumBItems = 1; /* No Boundary Items */
|
||||
|
||||
Pout<< "zoneName:" << zoneName
|
||||
<< " strandID:" << strandID
|
||||
//<< " varLocArray:" << varLocArray
|
||||
<< " solTime:" << SolTime
|
||||
<< endl;
|
||||
|
||||
|
||||
INTEGER4 *PassiveVarArray = NULL;
|
||||
INTEGER4 *VarShareArray = NULL;
|
||||
INTEGER4 ShrConn = 0;
|
||||
|
||||
|
||||
INTEGER4 ZoneType = ZoneType_Ordered;
|
||||
|
||||
if
|
||||
(
|
||||
!TECZNE112
|
||||
(
|
||||
const_cast<char*>(zoneName.c_str()),
|
||||
&ZoneType,
|
||||
&IMax,
|
||||
&JMax,
|
||||
&KMax,
|
||||
&ICellMax,
|
||||
&JCellMax,
|
||||
&KCellMax,
|
||||
&SolTime,
|
||||
&strandID,
|
||||
&ParentZone,
|
||||
&IsBlock,
|
||||
&NFConns,
|
||||
&FNMode,
|
||||
&NumFaceNodes,
|
||||
&NumBConns,
|
||||
&NumBItems,
|
||||
PassiveVarArray,
|
||||
const_cast<INTEGER4*>(varLocArray.begin()),
|
||||
VarShareArray,
|
||||
&ShrConn
|
||||
)
|
||||
)
|
||||
{
|
||||
// FatalErrorIn("tecplotWriter::writePolygonalZone(..) const")
|
||||
// << "Error in TECZNE112." << exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::tecplotWriter::writeConnectivity(const fvMesh& mesh) const
|
||||
{
|
||||
List<INTEGER4> FaceNodeCounts(mesh.nFaces());
|
||||
|
||||
forAll(mesh.faces(), faceI)
|
||||
{
|
||||
const face& f = mesh.faces()[faceI];
|
||||
FaceNodeCounts[faceI] = INTEGER4(f.size());
|
||||
}
|
||||
|
||||
|
||||
INTEGER4 nFaceNodes = 0;
|
||||
forAll(mesh.faces(), faceI)
|
||||
{
|
||||
nFaceNodes += mesh.faces()[faceI].size();
|
||||
}
|
||||
|
||||
|
||||
List<INTEGER4> FaceNodes(nFaceNodes);
|
||||
label nodeI = 0;
|
||||
forAll(mesh.faces(), faceI)
|
||||
{
|
||||
const face& f = mesh.faces()[faceI];
|
||||
forAll(f, fp)
|
||||
{
|
||||
FaceNodes[nodeI++] = INTEGER4(f[fp]+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<INTEGER4> FaceLeftElems(mesh.nFaces());
|
||||
forAll(mesh.faceOwner(), faceI)
|
||||
{
|
||||
FaceLeftElems[faceI] = mesh.faceOwner()[faceI]+1;
|
||||
}
|
||||
|
||||
List<INTEGER4> FaceRightElems(mesh.nFaces());
|
||||
forAll(mesh.faceNeighbour(), faceI)
|
||||
{
|
||||
FaceRightElems[faceI] = mesh.faceNeighbour()[faceI]+1;
|
||||
}
|
||||
for
|
||||
(
|
||||
label faceI = mesh.nInternalFaces();
|
||||
faceI < mesh.nFaces();
|
||||
faceI++
|
||||
)
|
||||
{
|
||||
FaceRightElems[faceI] = 0;
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
!TECPOLY112
|
||||
(
|
||||
FaceNodeCounts.begin(), /* The face node counts array */
|
||||
FaceNodes.begin(), /* The face nodes array */
|
||||
FaceLeftElems.begin(), /* The left elements array */
|
||||
FaceRightElems.begin(), /* The right elements array */
|
||||
NULL, /* No boundary connection counts */
|
||||
NULL, /* No boundary connection elements */
|
||||
NULL /* No boundary connection zones */
|
||||
)
|
||||
)
|
||||
{
|
||||
// FatalErrorIn("tecplotWriter::writeConnectivity(const fvMesh&) const")
|
||||
// << "Error in TECPOLY112." << exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::tecplotWriter::writeConnectivity
|
||||
(
|
||||
const indirectPrimitivePatch& pp
|
||||
) const
|
||||
{
|
||||
INTEGER4 NumFaces = pp.nEdges(); /* number of unique faces */
|
||||
INTEGER4 NumFaceNodes = 2*pp.nEdges();
|
||||
|
||||
// All faces (=edges) have 2 nodes
|
||||
List<INTEGER4> FaceNodeCounts(NumFaces, 2);
|
||||
|
||||
List<INTEGER4> FaceNodes(NumFaceNodes);
|
||||
label nodeI = 0;
|
||||
forAll(pp.edges(), edgeI)
|
||||
{
|
||||
edge e = pp.edges()[edgeI];
|
||||
if (e[0] > e[1])
|
||||
{
|
||||
e.flip();
|
||||
}
|
||||
|
||||
FaceNodes[nodeI++] = INTEGER4(e[0]+1);
|
||||
FaceNodes[nodeI++] = INTEGER4(e[1]+1);
|
||||
}
|
||||
|
||||
/* 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).
|
||||
*/
|
||||
|
||||
List<INTEGER4> FaceLeftElems(NumFaces);
|
||||
List<INTEGER4> FaceRightElems(NumFaces);
|
||||
|
||||
const labelListList& edgeFaces = pp.edgeFaces();
|
||||
forAll(edgeFaces, edgeI)
|
||||
{
|
||||
const labelList& eFaces = edgeFaces[edgeI];
|
||||
|
||||
if (eFaces.size() == 1)
|
||||
{
|
||||
FaceLeftElems[edgeI] = 0;
|
||||
FaceRightElems[edgeI] = eFaces[0]+1;
|
||||
}
|
||||
else if (eFaces.size() == 2)
|
||||
{
|
||||
edge e = pp.edges()[edgeI];
|
||||
if (e[0] > e[1])
|
||||
{
|
||||
e.flip();
|
||||
}
|
||||
|
||||
const face& f0 = pp.localFaces()[eFaces[0]];
|
||||
|
||||
// The face that uses the vertices of e in increasing order
|
||||
// is the left face.
|
||||
|
||||
label fp = findIndex(f0, e[0]);
|
||||
bool f0IsLeft = (f0.nextLabel(fp) == e[1]);
|
||||
|
||||
if (f0IsLeft)
|
||||
{
|
||||
FaceLeftElems[edgeI] = eFaces[0]+1;
|
||||
FaceRightElems[edgeI] = eFaces[1]+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
FaceLeftElems[edgeI] = eFaces[1]+1;
|
||||
FaceRightElems[edgeI] = eFaces[0]+1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// non-manifold. Treat as if open.
|
||||
FaceLeftElems[edgeI] = 0;
|
||||
FaceRightElems[edgeI] = eFaces[0]+1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Write the face map (created above) using TECPOLY112. */
|
||||
if
|
||||
(
|
||||
!TECPOLY112
|
||||
(
|
||||
FaceNodeCounts.begin(), /* The face node counts array */
|
||||
FaceNodes.begin(), /* The face nodes array */
|
||||
FaceLeftElems.begin(), /* The left elements array */
|
||||
FaceRightElems.begin(), /* The right elements array */
|
||||
NULL, /* No boundary connection counts */
|
||||
NULL, /* No boundary connection elements */
|
||||
NULL /* No boundary connection zones */
|
||||
)
|
||||
)
|
||||
{
|
||||
// FatalErrorIn("tecplotWriter::writeConnectivity(..) const")
|
||||
// << "Error in TECPOLY112." << exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::tecplotWriter::writeEnd() const
|
||||
{
|
||||
Pout<< "writeEnd" << endl;
|
||||
|
||||
if (!TECEND112())
|
||||
{
|
||||
// FatalErrorIn("tecplotWriter::writeEnd() const")
|
||||
// << "Error in TECEND112." << exit(FatalError);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,178 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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::tecplotWriter
|
||||
|
||||
Description
|
||||
Write binary tecplot files using tecio.
|
||||
|
||||
SourceFiles
|
||||
tecplotWriter.C
|
||||
tecplotWriterTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef tecplotWriter_H
|
||||
#define tecplotWriter_H
|
||||
|
||||
#include "TECIO.h"
|
||||
#include "Time.H"
|
||||
#include "indirectPrimitivePatch.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class fvMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class tecplotWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class tecplotWriter
|
||||
{
|
||||
const Time& runTime_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
tecplotWriter(const Time&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
void writeInit
|
||||
(
|
||||
const word& name,
|
||||
const string& varNames,
|
||||
const fileName&,
|
||||
INTEGER4 tecplotFileType
|
||||
) const;
|
||||
|
||||
//- Write mesh as polyhedral zone
|
||||
void writePolyhedralZone
|
||||
(
|
||||
const word& zoneName,
|
||||
const INTEGER4 strandID,
|
||||
const fvMesh& mesh,
|
||||
const List<INTEGER4>& varLocArray,
|
||||
INTEGER4 nFaceNodes
|
||||
) const;
|
||||
|
||||
//- Write surface as polygonal zone
|
||||
void writePolygonalZone
|
||||
(
|
||||
const word& zoneName,
|
||||
const INTEGER4 strandID,
|
||||
const indirectPrimitivePatch& pp,
|
||||
const List<INTEGER4>& varLocArray
|
||||
) const;
|
||||
|
||||
//- Write unordered data (or rather 1D ordered)
|
||||
void writeOrderedZone
|
||||
(
|
||||
const word& zoneName,
|
||||
INTEGER4 strandID,
|
||||
const label n,
|
||||
const List<INTEGER4>& varLocArray
|
||||
) const;
|
||||
|
||||
//- Write mesh
|
||||
void writeConnectivity(const fvMesh& mesh) const;
|
||||
|
||||
//- Write surface
|
||||
void writeConnectivity(const indirectPrimitivePatch& pp) const;
|
||||
|
||||
void writeEnd() const;
|
||||
|
||||
//- Write generic Field
|
||||
template<class Type>
|
||||
void writeField(const Field<Type>& fld) const;
|
||||
|
||||
|
||||
//- Get either fvPatchField or patchInternalField
|
||||
template<class Type>
|
||||
tmp<Field<Type> > getPatchField
|
||||
(
|
||||
const bool nearCellValue,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vfld,
|
||||
const label patchI
|
||||
) const;
|
||||
|
||||
//- Get mixed field: fvsPatchField for boundary faces and
|
||||
// internalField for internal faces.
|
||||
template<class Type>
|
||||
tmp<Field<Type> > getFaceField
|
||||
(
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>&,
|
||||
const labelList& faceLabels
|
||||
) const;
|
||||
|
||||
template<class GeoField>
|
||||
static wordList getNames(const PtrList<GeoField>&);
|
||||
|
||||
template<class Type>
|
||||
static void getTecplotNames
|
||||
(
|
||||
const wordList& names,
|
||||
const INTEGER4 loc,
|
||||
string& varNames,
|
||||
DynamicList<INTEGER4>& varLocation
|
||||
);
|
||||
|
||||
template<class GeoField>
|
||||
static void getTecplotNames
|
||||
(
|
||||
const PtrList<GeoField>& flds,
|
||||
const INTEGER4 loc,
|
||||
string& varNames,
|
||||
DynamicList<INTEGER4>& varLocation
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "tecplotWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,198 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//extern "C"
|
||||
//{
|
||||
#include "MASTER.h"
|
||||
#include "GLOBAL.h"
|
||||
//}
|
||||
|
||||
#include "tecplotWriter.H"
|
||||
|
||||
#include "fvc.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::tecplotWriter::writeField(const Field<Type>& fld) const
|
||||
{
|
||||
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
scalarField cmptFld(fld.component(cmpt));
|
||||
|
||||
// Convert to float
|
||||
Field<float> floats(cmptFld.size());
|
||||
forAll(cmptFld, i)
|
||||
{
|
||||
floats[i] = float(cmptFld[i]);
|
||||
}
|
||||
|
||||
INTEGER4 size = INTEGER4(floats.size());
|
||||
INTEGER4 IsDouble = 0; //float
|
||||
|
||||
//Pout<< "Writing component:" << cmpt << " of size:" << size
|
||||
// << " floats." << endl;
|
||||
|
||||
if (!TECDAT112(&size, floats.begin(), &IsDouble))
|
||||
{
|
||||
// FatalErrorIn("tecplotWriter::writeField(..) const")
|
||||
// << "Error in TECDAT112." << exit(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Field<Type> > Foam::tecplotWriter::getPatchField
|
||||
(
|
||||
const bool nearCellValue,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vfld,
|
||||
const label patchI
|
||||
) const
|
||||
{
|
||||
if (nearCellValue)
|
||||
{
|
||||
return vfld.boundaryField()[patchI].patchInternalField();
|
||||
}
|
||||
else
|
||||
{
|
||||
return vfld.boundaryField()[patchI];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Field<Type> > Foam::tecplotWriter::getFaceField
|
||||
(
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& sfld,
|
||||
const labelList& faceLabels
|
||||
) const
|
||||
{
|
||||
const polyBoundaryMesh& patches = sfld.mesh().boundaryMesh();
|
||||
|
||||
tmp<Field<Type> > tfld(new Field<Type>(faceLabels.size()));
|
||||
Field<Type>& fld = tfld();
|
||||
|
||||
forAll(faceLabels, i)
|
||||
{
|
||||
label faceI = faceLabels[i];
|
||||
|
||||
label patchI = patches.whichPatch(faceI);
|
||||
|
||||
if (patchI == -1)
|
||||
{
|
||||
fld[i] = sfld[faceI];
|
||||
}
|
||||
else
|
||||
{
|
||||
label localFaceI = faceI - patches[patchI].start();
|
||||
fld[i] = sfld.boundaryField()[patchI][localFaceI];
|
||||
}
|
||||
}
|
||||
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
template<class GeoField>
|
||||
Foam::wordList Foam::tecplotWriter::getNames
|
||||
(
|
||||
const PtrList<GeoField>& flds
|
||||
)
|
||||
{
|
||||
wordList names(flds.size());
|
||||
forAll(flds, i)
|
||||
{
|
||||
names[i] = flds[i].name();
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::tecplotWriter::getTecplotNames
|
||||
(
|
||||
const wordList& names,
|
||||
const INTEGER4 loc,
|
||||
string& varNames,
|
||||
DynamicList<INTEGER4>& varLocation
|
||||
)
|
||||
{
|
||||
forAll(names, i)
|
||||
{
|
||||
if (!varNames.empty())
|
||||
{
|
||||
varNames += " ";
|
||||
}
|
||||
|
||||
label nCmpts = pTraits<Type>::nComponents;
|
||||
|
||||
if (nCmpts == 1)
|
||||
{
|
||||
varNames += names[i];
|
||||
varLocation.append(loc);
|
||||
}
|
||||
else
|
||||
{
|
||||
for
|
||||
(
|
||||
direction cmpt = 0;
|
||||
cmpt < nCmpts;
|
||||
cmpt++
|
||||
)
|
||||
{
|
||||
string fldName =
|
||||
(cmpt != 0 ? " " : string::null)
|
||||
+ names[i]
|
||||
+ "_"
|
||||
+ pTraits<Type>::componentNames[cmpt];
|
||||
varNames += fldName;
|
||||
varLocation.append(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class GeoField>
|
||||
void Foam::tecplotWriter::getTecplotNames
|
||||
(
|
||||
const PtrList<GeoField>& flds,
|
||||
const INTEGER4 loc,
|
||||
string& varNames,
|
||||
DynamicList<INTEGER4>& varLocation
|
||||
)
|
||||
{
|
||||
getTecplotNames<typename GeoField::value_type>
|
||||
(
|
||||
getNames(flds),
|
||||
loc,
|
||||
varNames,
|
||||
varLocation
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,83 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "vtkMesh.H"
|
||||
#include "fvMeshSubset.H"
|
||||
#include "Time.H"
|
||||
#include "cellSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::vtkMesh::vtkMesh
|
||||
(
|
||||
fvMesh& baseMesh,
|
||||
const word& setName
|
||||
)
|
||||
:
|
||||
baseMesh_(baseMesh),
|
||||
subsetter_(baseMesh),
|
||||
setName_(setName)
|
||||
{
|
||||
if (setName.size())
|
||||
{
|
||||
// Read cellSet using whole mesh
|
||||
cellSet currentSet(baseMesh_, setName_);
|
||||
|
||||
// Set current subset
|
||||
subsetter_.setLargeCellSubset(currentSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate()
|
||||
{
|
||||
polyMesh::readUpdateState meshState = baseMesh_.readUpdate();
|
||||
|
||||
if (meshState != polyMesh::UNCHANGED)
|
||||
{
|
||||
// Note: since fvMeshSubset has no movePoints() functionality
|
||||
// reconstruct the subset even if only movement.
|
||||
|
||||
// topoPtr_.clear();
|
||||
|
||||
if (setName_.size())
|
||||
{
|
||||
Info<< "Subsetting mesh based on cellSet " << setName_ << endl;
|
||||
|
||||
// Read cellSet using whole mesh
|
||||
cellSet currentSet(baseMesh_, setName_);
|
||||
|
||||
subsetter_.setLargeCellSubset(currentSet);
|
||||
}
|
||||
}
|
||||
|
||||
return meshState;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,178 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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::vtkMesh
|
||||
|
||||
Description
|
||||
Encapsulation of VTK mesh data. Holds mesh or meshsubset and
|
||||
polyhedral-cell decomposition on it.
|
||||
|
||||
SourceFiles
|
||||
vtkMesh.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkMesh_H
|
||||
#define vtkMesh_H
|
||||
|
||||
#include "fvMeshSubset.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class Time;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class vtkMesh Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class vtkMesh
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference to mesh
|
||||
fvMesh& baseMesh_;
|
||||
|
||||
//- Subsetting engine + sub-fvMesh
|
||||
fvMeshSubset subsetter_;
|
||||
|
||||
//- Current cellSet (or empty)
|
||||
const word setName_;
|
||||
|
||||
// //- Current decomposition of topology
|
||||
// mutable autoPtr<vtkTopo> topoPtr_;
|
||||
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
vtkMesh(const vtkMesh&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const vtkMesh&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
vtkMesh(fvMesh& baseMesh, const word& setName = "");
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- whole mesh
|
||||
const fvMesh& baseMesh() const
|
||||
{
|
||||
return baseMesh_;
|
||||
}
|
||||
|
||||
const fvMeshSubset& subsetter() const
|
||||
{
|
||||
return subsetter_;
|
||||
}
|
||||
|
||||
//- Check if running subMesh
|
||||
bool useSubMesh() const
|
||||
{
|
||||
return setName_.size();
|
||||
}
|
||||
|
||||
// //- topology
|
||||
// const vtkTopo& topo() const
|
||||
// {
|
||||
// if (topoPtr_.empty())
|
||||
// {
|
||||
// topoPtr_.reset(new vtkTopo(mesh()));
|
||||
// }
|
||||
// return topoPtr_();
|
||||
// }
|
||||
|
||||
//- Access either mesh or submesh
|
||||
const fvMesh& mesh() const
|
||||
{
|
||||
if (useSubMesh())
|
||||
{
|
||||
return subsetter_.subMesh();
|
||||
}
|
||||
else
|
||||
{
|
||||
return baseMesh_;
|
||||
}
|
||||
}
|
||||
|
||||
// //- Number of field cells
|
||||
// label nFieldCells() const
|
||||
// {
|
||||
// return topo().vertLabels().size();
|
||||
// }
|
||||
//
|
||||
// //- Number of field points
|
||||
// label nFieldPoints() const
|
||||
// {
|
||||
// return mesh().nPoints() + topo().addPointCellLabels().size();
|
||||
// }
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Read mesh
|
||||
polyMesh::readUpdateState readUpdate();
|
||||
|
||||
|
||||
//- Map volume field (does in fact do very little interpolation;
|
||||
// just copied from fvMeshSubset)
|
||||
template<class GeoField>
|
||||
tmp<GeoField> interpolate(const GeoField& fld) const
|
||||
{
|
||||
if (useSubMesh())
|
||||
{
|
||||
tmp<GeoField> subFld = subsetter_.interpolate(fld);
|
||||
subFld().rename(fld.name());
|
||||
return subFld;
|
||||
}
|
||||
else
|
||||
{
|
||||
return fld;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,4 @@
|
||||
|
||||
foamToTetDualMesh.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/foamToTetDualMesh
|
||||
@ -0,0 +1,5 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume
|
||||
@ -0,0 +1,312 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Application
|
||||
foamToTetDualMesh
|
||||
|
||||
Description
|
||||
Converts polyMesh results to tetDualMesh.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "argList.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "pointFields.H"
|
||||
#include "Time.H"
|
||||
#include "IOobjectList.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ReadGeoField, class MappedGeoField>
|
||||
void ReadAndMapFields
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
const fvMesh& tetDualMesh,
|
||||
const labelList& map,
|
||||
const typename MappedGeoField::value_type& nullValue,
|
||||
PtrList<MappedGeoField>& tetFields
|
||||
)
|
||||
{
|
||||
typedef typename MappedGeoField::value_type Type;
|
||||
|
||||
// Search list of objects for wanted type
|
||||
IOobjectList fieldObjects(objects.lookupClass(ReadGeoField::typeName));
|
||||
|
||||
tetFields.setSize(fieldObjects.size());
|
||||
|
||||
label i = 0;
|
||||
forAllConstIter(IOobjectList, fieldObjects, iter)
|
||||
{
|
||||
Info<< "Converting " << ReadGeoField::typeName << ' ' << iter.key()
|
||||
<< endl;
|
||||
|
||||
ReadGeoField readField(*iter(), mesh);
|
||||
|
||||
tetFields.set
|
||||
(
|
||||
i,
|
||||
new MappedGeoField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
readField.name(),
|
||||
readField.instance(),
|
||||
readField.local(),
|
||||
tetDualMesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE,
|
||||
readField.registerObject()
|
||||
),
|
||||
pointMesh::New(tetDualMesh),
|
||||
dimensioned<Type>
|
||||
(
|
||||
"zero",
|
||||
readField.dimensions(),
|
||||
pTraits<Type>::zero
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Field<Type>& fld = tetFields[i].internalField();
|
||||
|
||||
// Map from read field. Set unmapped entries to nullValue.
|
||||
fld.setSize(map.size(), nullValue);
|
||||
forAll(map, pointI)
|
||||
{
|
||||
label index = map[pointI];
|
||||
|
||||
if (index > 0)
|
||||
{
|
||||
label cellI = index-1;
|
||||
fld[pointI] = readField[cellI];
|
||||
}
|
||||
else if (index < 0)
|
||||
{
|
||||
label faceI = -index-1;
|
||||
label bFaceI = faceI - mesh.nInternalFaces();
|
||||
if (bFaceI >= 0)
|
||||
{
|
||||
label patchI = mesh.boundaryMesh().patchID()[bFaceI];
|
||||
label localFaceI = mesh.boundaryMesh()[patchI].whichFace
|
||||
(
|
||||
faceI
|
||||
);
|
||||
fld[pointI] = readField.boundaryField()[patchI][localFaceI];
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// FatalErrorIn("ReadAndMapFields(..)")
|
||||
// << "Face " << faceI << " from index " << index
|
||||
// << " is not a boundary face." << abort(FatalError);
|
||||
//}
|
||||
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// WarningIn("ReadAndMapFields(..)")
|
||||
// << "Point " << pointI << " at "
|
||||
// << tetDualMesh.points()[pointI]
|
||||
// << " has no dual correspondence." << endl;
|
||||
//}
|
||||
}
|
||||
tetFields[i].correctBoundaryConditions();
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "addOverwriteOption.H"
|
||||
# include "addTimeOptions.H"
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
// Get times list
|
||||
instantList Times = runTime.times();
|
||||
# include "checkTimeOptions.H"
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
|
||||
|
||||
// Read the mesh
|
||||
# include "createMesh.H"
|
||||
|
||||
// Read the tetDualMesh
|
||||
Info<< "Create tetDualMesh for time = "
|
||||
<< runTime.timeName() << nl << endl;
|
||||
|
||||
fvMesh tetDualMesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"tetDualMesh",
|
||||
runTime.timeName(),
|
||||
runTime,
|
||||
IOobject::MUST_READ
|
||||
)
|
||||
);
|
||||
// From tet vertices to poly cells/faces
|
||||
const labelIOList pointDualAddressing
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pointDualAddressing",
|
||||
tetDualMesh.facesInstance(),
|
||||
tetDualMesh.meshSubDir,
|
||||
tetDualMesh,
|
||||
IOobject::MUST_READ
|
||||
)
|
||||
);
|
||||
|
||||
if (pointDualAddressing.size() != tetDualMesh.nPoints())
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Size " << pointDualAddressing.size()
|
||||
<< " of addressing map " << pointDualAddressing.objectPath()
|
||||
<< " differs from number of points in mesh "
|
||||
<< tetDualMesh.nPoints()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
// Some stats on addressing
|
||||
label nCells = 0;
|
||||
label nPatchFaces = 0;
|
||||
label nUnmapped = 0;
|
||||
forAll(pointDualAddressing, pointI)
|
||||
{
|
||||
label index = pointDualAddressing[pointI];
|
||||
|
||||
if (index > 0)
|
||||
{
|
||||
nCells++;
|
||||
}
|
||||
else if (index == 0)
|
||||
{
|
||||
nUnmapped++;
|
||||
}
|
||||
else
|
||||
{
|
||||
label faceI = -index-1;
|
||||
if (faceI < mesh.nInternalFaces())
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Face " << faceI << " from index " << index
|
||||
<< " is not a boundary face."
|
||||
<< " nInternalFaces:" << mesh.nInternalFaces()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
else
|
||||
{
|
||||
nPatchFaces++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reduce(nCells, sumOp<label>());
|
||||
reduce(nPatchFaces, sumOp<label>());
|
||||
reduce(nUnmapped, sumOp<label>());
|
||||
Info<< "tetDualMesh points : " << tetDualMesh.nPoints()
|
||||
<< " of which mapped to" << nl
|
||||
<< " cells : " << nCells << nl
|
||||
<< " patch faces : " << nPatchFaces << nl
|
||||
<< " not mapped : " << nUnmapped << nl
|
||||
<< endl;
|
||||
|
||||
|
||||
// Read objects in time directory
|
||||
IOobjectList objects(mesh, runTime.timeName());
|
||||
|
||||
// Read vol fields, interpolate onto tet points
|
||||
PtrList<pointScalarField> psFlds;
|
||||
ReadAndMapFields<volScalarField, pointScalarField>
|
||||
(
|
||||
mesh,
|
||||
objects,
|
||||
tetDualMesh,
|
||||
pointDualAddressing,
|
||||
pTraits<scalar>::zero, // nullValue
|
||||
psFlds
|
||||
);
|
||||
|
||||
PtrList<pointVectorField> pvFlds;
|
||||
ReadAndMapFields<volVectorField, pointVectorField>
|
||||
(
|
||||
mesh,
|
||||
objects,
|
||||
tetDualMesh,
|
||||
pointDualAddressing,
|
||||
pTraits<vector>::zero, // nullValue
|
||||
pvFlds
|
||||
);
|
||||
|
||||
PtrList<pointSphericalTensorField> pstFlds;
|
||||
ReadAndMapFields<volSphericalTensorField, pointSphericalTensorField>
|
||||
(
|
||||
mesh,
|
||||
objects,
|
||||
tetDualMesh,
|
||||
pointDualAddressing,
|
||||
pTraits<sphericalTensor>::zero, // nullValue
|
||||
pstFlds
|
||||
);
|
||||
|
||||
PtrList<pointSymmTensorField> psymmtFlds;
|
||||
ReadAndMapFields<volSymmTensorField, pointSymmTensorField>
|
||||
(
|
||||
mesh,
|
||||
objects,
|
||||
tetDualMesh,
|
||||
pointDualAddressing,
|
||||
pTraits<symmTensor>::zero, // nullValue
|
||||
psymmtFlds
|
||||
);
|
||||
|
||||
PtrList<pointTensorField> ptFlds;
|
||||
ReadAndMapFields<volTensorField, pointTensorField>
|
||||
(
|
||||
mesh,
|
||||
objects,
|
||||
tetDualMesh,
|
||||
pointDualAddressing,
|
||||
pTraits<tensor>::zero, // nullValue
|
||||
ptFlds
|
||||
);
|
||||
|
||||
tetDualMesh.objectRegistry::write();
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,15 @@
|
||||
surfaceMeshWriter.C
|
||||
|
||||
foamToVTK.C
|
||||
internalWriter.C
|
||||
lagrangianWriter.C
|
||||
patchWriter.C
|
||||
writeFuns.C
|
||||
writeFaceSet.C
|
||||
writePointSet.C
|
||||
writeSurfFields.C
|
||||
|
||||
vtkMesh.C
|
||||
vtkTopo.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/foamToVTK
|
||||
@ -0,0 +1,11 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-llagrangian \
|
||||
-lgenericPatchFields \
|
||||
-lmeshTools
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,165 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "internalWriter.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::internalWriter::internalWriter
|
||||
(
|
||||
const vtkMesh& vMesh,
|
||||
const bool binary,
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
vMesh_(vMesh),
|
||||
binary_(binary),
|
||||
fName_(fName),
|
||||
os_(fName.c_str())
|
||||
{
|
||||
const fvMesh& mesh = vMesh_.mesh();
|
||||
const vtkTopo& topo = vMesh_.topo();
|
||||
|
||||
// Write header
|
||||
writeFuns::writeHeader(os_, binary_, mesh.time().caseName());
|
||||
os_ << "DATASET UNSTRUCTURED_GRID" << std::endl;
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Write topology
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
const labelList& addPointCellLabels = topo.addPointCellLabels();
|
||||
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
|
||||
|
||||
os_ << "POINTS " << nTotPoints << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> ptField(3*nTotPoints);
|
||||
|
||||
writeFuns::insert(mesh.points(), ptField);
|
||||
|
||||
const pointField& ctrs = mesh.cellCentres();
|
||||
forAll(addPointCellLabels, api)
|
||||
{
|
||||
writeFuns::insert(ctrs[addPointCellLabels[api]], ptField);
|
||||
}
|
||||
writeFuns::write(os_, binary_, ptField);
|
||||
|
||||
|
||||
//
|
||||
// Write cells
|
||||
//
|
||||
|
||||
const labelListList& vtkVertLabels = topo.vertLabels();
|
||||
|
||||
// Count total number of vertices referenced.
|
||||
label nFaceVerts = 0;
|
||||
|
||||
forAll(vtkVertLabels, cellI)
|
||||
{
|
||||
nFaceVerts += vtkVertLabels[cellI].size() + 1;
|
||||
}
|
||||
|
||||
os_ << "CELLS " << vtkVertLabels.size() << ' ' << nFaceVerts << std::endl;
|
||||
|
||||
DynamicList<label> vertLabels(nFaceVerts);
|
||||
|
||||
forAll(vtkVertLabels, cellI)
|
||||
{
|
||||
const labelList& vtkVerts = vtkVertLabels[cellI];
|
||||
|
||||
vertLabels.append(vtkVerts.size());
|
||||
|
||||
writeFuns::insert(vtkVerts, vertLabels);
|
||||
}
|
||||
writeFuns::write(os_, binary_, vertLabels);
|
||||
|
||||
|
||||
const labelList& vtkCellTypes = topo.cellTypes();
|
||||
|
||||
os_ << "CELL_TYPES " << vtkCellTypes.size() << std::endl;
|
||||
|
||||
// Make copy since writing might swap stuff.
|
||||
DynamicList<label> cellTypes(vtkCellTypes.size());
|
||||
|
||||
writeFuns::insert(vtkCellTypes, cellTypes);
|
||||
|
||||
writeFuns::write(os_, binary_, cellTypes);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::internalWriter::writeCellIDs()
|
||||
{
|
||||
const fvMesh& mesh = vMesh_.mesh();
|
||||
const vtkTopo& topo = vMesh_.topo();
|
||||
const labelList& vtkCellTypes = topo.cellTypes();
|
||||
const labelList& superCells = topo.superCells();
|
||||
|
||||
// Cell ids first
|
||||
os_ << "cellID 1 " << vtkCellTypes.size() << " int" << std::endl;
|
||||
|
||||
labelList cellId(vtkCellTypes.size());
|
||||
label labelI = 0;
|
||||
|
||||
|
||||
if (vMesh_.useSubMesh())
|
||||
{
|
||||
const labelList& cMap = vMesh_.subsetter().cellMap();
|
||||
|
||||
forAll(mesh.cells(), cellI)
|
||||
{
|
||||
cellId[labelI++] = cMap[cellI];
|
||||
}
|
||||
forAll(superCells, superCellI)
|
||||
{
|
||||
label origCellI = cMap[superCells[superCellI]];
|
||||
|
||||
cellId[labelI++] = origCellI;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(mesh.cells(), cellI)
|
||||
{
|
||||
cellId[labelI++] = cellI;
|
||||
}
|
||||
forAll(superCells, superCellI)
|
||||
{
|
||||
label origCellI = superCells[superCellI];
|
||||
|
||||
cellId[labelI++] = origCellI;
|
||||
}
|
||||
}
|
||||
|
||||
writeFuns::write(os_, binary_, cellId);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,122 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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::internalWriter
|
||||
|
||||
Description
|
||||
Write fields (internal).
|
||||
|
||||
SourceFiles
|
||||
internalWriter.C
|
||||
internalWriterTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef internalWriter_H
|
||||
#define internalWriter_H
|
||||
|
||||
#include "OFstream.H"
|
||||
#include "volFields.H"
|
||||
#include "pointFields.H"
|
||||
#include "vtkMesh.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class volPointInterpolation;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class internalWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class internalWriter
|
||||
{
|
||||
const vtkMesh& vMesh_;
|
||||
|
||||
const bool binary_;
|
||||
|
||||
const fileName fName_;
|
||||
|
||||
std::ofstream os_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
internalWriter
|
||||
(
|
||||
const vtkMesh&,
|
||||
const bool binary,
|
||||
const fileName&
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
std::ofstream& os()
|
||||
{
|
||||
return os_;
|
||||
}
|
||||
|
||||
//- Write cellIDs
|
||||
void writeCellIDs();
|
||||
|
||||
//- Write generic GeometricFields
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void write
|
||||
(
|
||||
const PtrList<GeometricField<Type, PatchField, GeoMesh> >&
|
||||
);
|
||||
|
||||
//- Interpolate and write volFields
|
||||
template<class Type>
|
||||
void write
|
||||
(
|
||||
const volPointInterpolation&,
|
||||
const PtrList<GeometricField<Type, fvPatchField, volMesh> >&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "internalWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,65 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "internalWriter.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::internalWriter::write
|
||||
(
|
||||
const PtrList<GeometricField<Type, PatchField, GeoMesh> >& flds
|
||||
)
|
||||
{
|
||||
forAll(flds, i)
|
||||
{
|
||||
writeFuns::write(os_, binary_, flds[i], vMesh_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::internalWriter::write
|
||||
(
|
||||
const volPointInterpolation& pInterp,
|
||||
const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds
|
||||
)
|
||||
{
|
||||
forAll(flds, i)
|
||||
{
|
||||
writeFuns::write
|
||||
(
|
||||
os_,
|
||||
binary_,
|
||||
flds[i],
|
||||
pInterp.interpolate(flds[i])(),
|
||||
vMesh_
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,89 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "lagrangianWriter.H"
|
||||
#include "writeFuns.H"
|
||||
#include "Cloud.H"
|
||||
#include "passiveParticle.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::lagrangianWriter::lagrangianWriter
|
||||
(
|
||||
const vtkMesh& vMesh,
|
||||
const bool binary,
|
||||
const fileName& fName,
|
||||
const word& cloudName,
|
||||
const bool dummyCloud
|
||||
)
|
||||
:
|
||||
vMesh_(vMesh),
|
||||
binary_(binary),
|
||||
fName_(fName),
|
||||
cloudName_(cloudName),
|
||||
os_(fName.c_str())
|
||||
{
|
||||
const fvMesh& mesh = vMesh_.mesh();
|
||||
|
||||
// Write header
|
||||
writeFuns::writeHeader(os_, binary_, mesh.time().caseName());
|
||||
os_ << "DATASET POLYDATA" << std::endl;
|
||||
|
||||
if (dummyCloud)
|
||||
{
|
||||
nParcels_ = 0;
|
||||
|
||||
os_ << "POINTS " << nParcels_ << " float" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cloud<passiveParticle> parcels(mesh, cloudName_, false);
|
||||
|
||||
nParcels_ = parcels.size();
|
||||
|
||||
os_ << "POINTS " << nParcels_ << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> partField(3*parcels.size());
|
||||
|
||||
forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
|
||||
{
|
||||
writeFuns::insert(elmnt().position(), partField);
|
||||
}
|
||||
writeFuns::write(os_, binary_, partField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::lagrangianWriter::writeParcelHeader(const label nFields)
|
||||
{
|
||||
os_ << "POINT_DATA " << nParcels_ << std::endl
|
||||
<< "FIELD attributes " << nFields
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,118 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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::lagrangianWriter
|
||||
|
||||
Description
|
||||
Write fields (internal).
|
||||
|
||||
SourceFiles
|
||||
lagrangianWriter.C
|
||||
lagrangianWriterTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef lagrangianWriter_H
|
||||
#define lagrangianWriter_H
|
||||
|
||||
#include "OFstream.H"
|
||||
#include "Cloud.H"
|
||||
#include "volFields.H"
|
||||
#include "pointFields.H"
|
||||
#include "vtkMesh.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class volPointInterpolation;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class lagrangianWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class lagrangianWriter
|
||||
{
|
||||
const vtkMesh& vMesh_;
|
||||
|
||||
const bool binary_;
|
||||
|
||||
const fileName fName_;
|
||||
|
||||
const word cloudName_;
|
||||
|
||||
std::ofstream os_;
|
||||
|
||||
label nParcels_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
lagrangianWriter
|
||||
(
|
||||
const vtkMesh&,
|
||||
const bool binary,
|
||||
const fileName&,
|
||||
const word&,
|
||||
const bool dummyCloud
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
std::ofstream& os()
|
||||
{
|
||||
return os_;
|
||||
}
|
||||
|
||||
void writeParcelHeader(const label nFields);
|
||||
|
||||
//- Write IOField
|
||||
template<class Type>
|
||||
void writeIOField(const wordList&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "lagrangianWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,64 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "lagrangianWriter.H"
|
||||
#include "writeFuns.H"
|
||||
#include "IOField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::lagrangianWriter::writeIOField(const wordList& objects)
|
||||
{
|
||||
forAll(objects, i)
|
||||
{
|
||||
const word& object = objects[i];
|
||||
|
||||
IOobject header
|
||||
(
|
||||
object,
|
||||
vMesh_.mesh().time().timeName(),
|
||||
cloud::prefix/cloudName_,
|
||||
vMesh_.mesh(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
IOField<Type> fld(header);
|
||||
|
||||
os_ << object << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< fld.size() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*fld.size());
|
||||
|
||||
writeFuns::insert(fld, fField);
|
||||
|
||||
writeFuns::write(os_, binary_, fField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,139 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "patchWriter.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::patchWriter::patchWriter
|
||||
(
|
||||
const vtkMesh& vMesh,
|
||||
const bool binary,
|
||||
const bool nearCellValue,
|
||||
const fileName& fName,
|
||||
const labelList& patchIDs
|
||||
)
|
||||
:
|
||||
vMesh_(vMesh),
|
||||
binary_(binary),
|
||||
nearCellValue_(nearCellValue),
|
||||
fName_(fName),
|
||||
patchIDs_(patchIDs),
|
||||
os_(fName.c_str())
|
||||
{
|
||||
const fvMesh& mesh = vMesh_.mesh();
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
// Write header
|
||||
if (patchIDs_.size() == 1)
|
||||
{
|
||||
writeFuns::writeHeader(os_, binary_, patches[patchIDs_[0]].name());
|
||||
}
|
||||
else
|
||||
{
|
||||
writeFuns::writeHeader(os_, binary_, "patches");
|
||||
}
|
||||
os_ << "DATASET POLYDATA" << std::endl;
|
||||
|
||||
// Write topology
|
||||
nPoints_ = 0;
|
||||
nFaces_ = 0;
|
||||
label nFaceVerts = 0;
|
||||
|
||||
forAll(patchIDs_, i)
|
||||
{
|
||||
const polyPatch& pp = patches[patchIDs_[i]];
|
||||
|
||||
nPoints_ += pp.nPoints();
|
||||
nFaces_ += pp.size();
|
||||
|
||||
forAll(pp, faceI)
|
||||
{
|
||||
nFaceVerts += pp[faceI].size() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
os_ << "POINTS " << nPoints_ << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> ptField(3*nPoints_);
|
||||
|
||||
forAll(patchIDs_, i)
|
||||
{
|
||||
const polyPatch& pp = patches[patchIDs_[i]];
|
||||
|
||||
writeFuns::insert(pp.localPoints(), ptField);
|
||||
}
|
||||
writeFuns::write(os_, binary_, ptField);
|
||||
|
||||
os_ << "POLYGONS " << nFaces_ << ' ' << nFaceVerts << std::endl;
|
||||
|
||||
DynamicList<label> vertLabels(nFaceVerts);
|
||||
|
||||
label offset = 0;
|
||||
|
||||
forAll(patchIDs_, i)
|
||||
{
|
||||
const polyPatch& pp = patches[patchIDs_[i]];
|
||||
|
||||
forAll(pp, faceI)
|
||||
{
|
||||
const face& f = pp.localFaces()[faceI];
|
||||
|
||||
vertLabels.append(f.size());
|
||||
writeFuns::insert(f + offset, vertLabels);
|
||||
}
|
||||
offset += pp.nPoints();
|
||||
}
|
||||
writeFuns::write(os_, binary_, vertLabels);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::patchWriter::writePatchIDs()
|
||||
{
|
||||
const fvMesh& mesh = vMesh_.mesh();
|
||||
|
||||
DynamicList<floatScalar> fField(nFaces_);
|
||||
|
||||
os_ << "patchID 1 " << nFaces_ << " float" << std::endl;
|
||||
|
||||
forAll(patchIDs_, i)
|
||||
{
|
||||
label patchI = patchIDs_[i];
|
||||
|
||||
const polyPatch& pp = mesh.boundaryMesh()[patchI];
|
||||
|
||||
if (!isA<emptyPolyPatch>(pp))
|
||||
{
|
||||
writeFuns::insert(scalarField(pp.size(), patchI), fField);
|
||||
}
|
||||
}
|
||||
writeFuns::write(os_, binary_, fField);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,152 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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::patchWriter
|
||||
|
||||
Description
|
||||
Write patch fields
|
||||
|
||||
SourceFiles
|
||||
patchWriter.C
|
||||
patchWriterTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef patchWriter_H
|
||||
#define patchWriter_H
|
||||
|
||||
#include "pointMesh.H"
|
||||
#include "OFstream.H"
|
||||
#include "volFields.H"
|
||||
#include "pointFields.H"
|
||||
#include "vtkMesh.H"
|
||||
#include "indirectPrimitivePatch.H"
|
||||
#include "PrimitivePatchInterpolation.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class volPointInterpolation;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class patchWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class patchWriter
|
||||
{
|
||||
const vtkMesh& vMesh_;
|
||||
|
||||
const bool binary_;
|
||||
|
||||
const bool nearCellValue_;
|
||||
|
||||
const fileName fName_;
|
||||
|
||||
const labelList patchIDs_;
|
||||
|
||||
std::ofstream os_;
|
||||
|
||||
label nPoints_;
|
||||
|
||||
label nFaces_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
patchWriter
|
||||
(
|
||||
const vtkMesh&,
|
||||
const bool binary,
|
||||
const bool nearCellValue,
|
||||
const fileName&,
|
||||
const labelList& patchIDs
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
std::ofstream& os()
|
||||
{
|
||||
return os_;
|
||||
}
|
||||
|
||||
label nPoints() const
|
||||
{
|
||||
return nPoints_;
|
||||
}
|
||||
|
||||
label nFaces() const
|
||||
{
|
||||
return nFaces_;
|
||||
}
|
||||
|
||||
//- Write cellIDs
|
||||
void writePatchIDs();
|
||||
|
||||
//- Write volFields
|
||||
template<class Type>
|
||||
void write
|
||||
(
|
||||
const PtrList<GeometricField<Type, fvPatchField, volMesh> >&
|
||||
);
|
||||
|
||||
//- Write pointFields
|
||||
template<class Type>
|
||||
void write
|
||||
(
|
||||
const PtrList<GeometricField<Type, pointPatchField, pointMesh> >&
|
||||
);
|
||||
|
||||
//- Interpolate and write volFields
|
||||
template<class Type>
|
||||
void write
|
||||
(
|
||||
const PrimitivePatchInterpolation<primitivePatch>&,
|
||||
const PtrList<GeometricField<Type, fvPatchField, volMesh> >&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "patchWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,142 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "patchWriter.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::patchWriter::write
|
||||
(
|
||||
const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds
|
||||
)
|
||||
{
|
||||
forAll(flds, fieldI)
|
||||
{
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldI];
|
||||
|
||||
os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< nFaces_ << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nFaces_);
|
||||
|
||||
forAll(patchIDs_, j)
|
||||
{
|
||||
label patchI = patchIDs_[j];
|
||||
|
||||
const fvPatchField<Type>& pfld = fld.boundaryField()[patchI];
|
||||
|
||||
if (nearCellValue_)
|
||||
{
|
||||
writeFuns::insert(pfld.patchInternalField()(), fField);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeFuns::insert(pfld, fField);
|
||||
}
|
||||
}
|
||||
writeFuns::write(os_, binary_, fField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::patchWriter::write
|
||||
(
|
||||
const PtrList<GeometricField<Type, pointPatchField, pointMesh> >& flds
|
||||
)
|
||||
{
|
||||
forAll(flds, fieldI)
|
||||
{
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& fld =
|
||||
flds[fieldI];
|
||||
|
||||
os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< nPoints_ << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
|
||||
|
||||
forAll(patchIDs_, j)
|
||||
{
|
||||
label patchI = patchIDs_[j];
|
||||
|
||||
const pointPatchField<Type>& pfld = fld.boundaryField()[patchI];
|
||||
|
||||
writeFuns::insert(pfld.patchInternalField()(), fField);
|
||||
}
|
||||
writeFuns::write(os_, binary_, fField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::patchWriter::write
|
||||
(
|
||||
const PrimitivePatchInterpolation<primitivePatch>& pInter,
|
||||
const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds
|
||||
)
|
||||
{
|
||||
forAll(flds, fieldI)
|
||||
{
|
||||
const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldI];
|
||||
|
||||
os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< nPoints_ << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
|
||||
|
||||
forAll(patchIDs_, j)
|
||||
{
|
||||
label patchI = patchIDs_[j];
|
||||
|
||||
const fvPatchField<Type>& pfld = fld.boundaryField()[patchI];
|
||||
|
||||
if (nearCellValue_)
|
||||
{
|
||||
writeFuns::insert
|
||||
(
|
||||
pInter.faceToPointInterpolate
|
||||
(
|
||||
pfld.patchInternalField()()
|
||||
)(),
|
||||
fField
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeFuns::insert
|
||||
(
|
||||
pInter.faceToPointInterpolate(pfld)(),
|
||||
fField
|
||||
);
|
||||
}
|
||||
}
|
||||
writeFuns::write(os_, binary_, fField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,81 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "readFields.H"
|
||||
#include "IOobjectList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class GeoField>
|
||||
void readFields
|
||||
(
|
||||
const vtkMesh& vMesh,
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
const HashSet<word>& selectedFields,
|
||||
PtrList<GeoField>& fields
|
||||
)
|
||||
{
|
||||
// Search list of objects for volScalarFields
|
||||
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
|
||||
|
||||
// Construct the vol scalar fields
|
||||
fields.setSize(fieldObjects.size());
|
||||
label nFields = 0;
|
||||
|
||||
forAllIter(IOobjectList, fieldObjects, iter)
|
||||
{
|
||||
if (selectedFields.empty() || selectedFields.found(iter()->name()))
|
||||
{
|
||||
fields.set
|
||||
(
|
||||
nFields,
|
||||
vMesh.interpolate
|
||||
(
|
||||
GeoField
|
||||
(
|
||||
*iter(),
|
||||
mesh
|
||||
)
|
||||
)
|
||||
);
|
||||
nFields++;
|
||||
}
|
||||
}
|
||||
|
||||
fields.setSize(nFields);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,70 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InClass
|
||||
Foam::readFields
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
readFields.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef readFields_H
|
||||
#define readFields_H
|
||||
|
||||
#include "fvMesh.H"
|
||||
#include "PtrList.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Read the fields and optionally subset and put on the pointer list
|
||||
template<class GeoField>
|
||||
void readFields
|
||||
(
|
||||
const vtkMesh& vMesh,
|
||||
const typename GeoField::Mesh& mesh,
|
||||
const IOobjectList& objects,
|
||||
const HashSet<word>& selectedFields,
|
||||
PtrList<GeoField>& fields
|
||||
);
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "readFields.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,79 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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 "surfaceMeshWriter.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfaceMeshWriter::surfaceMeshWriter
|
||||
(
|
||||
const bool binary,
|
||||
const indirectPrimitivePatch& pp,
|
||||
const word& name,
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
binary_(binary),
|
||||
pp_(pp),
|
||||
fName_(fName),
|
||||
os_(fName.c_str())
|
||||
{
|
||||
// Write header
|
||||
writeFuns::writeHeader(os_, binary_, name);
|
||||
|
||||
os_ << "DATASET POLYDATA" << std::endl;
|
||||
|
||||
// Write topology
|
||||
label nFaceVerts = 0;
|
||||
|
||||
forAll(pp, faceI)
|
||||
{
|
||||
nFaceVerts += pp[faceI].size() + 1;
|
||||
}
|
||||
|
||||
os_ << "POINTS " << pp.nPoints() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> ptField(3*pp.nPoints());
|
||||
writeFuns::insert(pp.localPoints(), ptField);
|
||||
writeFuns::write(os_, binary, ptField);
|
||||
|
||||
|
||||
os_ << "POLYGONS " << pp.size() << ' ' << nFaceVerts << std::endl;
|
||||
|
||||
DynamicList<label> vertLabels(nFaceVerts);
|
||||
|
||||
forAll(pp, faceI)
|
||||
{
|
||||
const face& f = pp.localFaces()[faceI];
|
||||
|
||||
vertLabels.append(f.size());
|
||||
writeFuns::insert(f, vertLabels);
|
||||
}
|
||||
writeFuns::write(os_, binary_, vertLabels);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,122 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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::surfaceMeshWriter
|
||||
|
||||
Description
|
||||
Write faces with fields
|
||||
|
||||
SourceFiles
|
||||
surfaceMeshWriter.C
|
||||
surfaceMeshWriterTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfaceMeshWriter_H
|
||||
#define surfaceMeshWriter_H
|
||||
|
||||
#include "pointMesh.H"
|
||||
#include "OFstream.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "vtkMesh.H"
|
||||
#include "indirectPrimitivePatch.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class volPointInterpolation;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfaceMeshWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfaceMeshWriter
|
||||
{
|
||||
const bool binary_;
|
||||
|
||||
const indirectPrimitivePatch& pp_;
|
||||
|
||||
const fileName fName_;
|
||||
|
||||
std::ofstream os_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
surfaceMeshWriter
|
||||
(
|
||||
const bool binary,
|
||||
const indirectPrimitivePatch& pp,
|
||||
const word& name,
|
||||
const fileName&
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
std::ofstream& os()
|
||||
{
|
||||
return os_;
|
||||
}
|
||||
|
||||
//- Extract face data
|
||||
template<class Type>
|
||||
tmp<Field<Type> > getFaceField
|
||||
(
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>&
|
||||
) const;
|
||||
|
||||
//- Write surfaceFields
|
||||
template<class Type>
|
||||
void write
|
||||
(
|
||||
const PtrList<GeometricField<Type, fvsPatchField, surfaceMesh> >&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "surfaceMeshWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,84 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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 "surfaceMeshWriter.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Field<Type> > Foam::surfaceMeshWriter::getFaceField
|
||||
(
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& sfld
|
||||
) const
|
||||
{
|
||||
const polyBoundaryMesh& patches = sfld.mesh().boundaryMesh();
|
||||
|
||||
tmp<Field<Type> > tfld(new Field<Type>(pp_.size()));
|
||||
Field<Type>& fld = tfld();
|
||||
|
||||
forAll(pp_.addressing(), i)
|
||||
{
|
||||
label faceI = pp_.addressing()[i];
|
||||
|
||||
label patchI = patches.whichPatch(faceI);
|
||||
|
||||
if (patchI == -1)
|
||||
{
|
||||
fld[i] = sfld[faceI];
|
||||
}
|
||||
else
|
||||
{
|
||||
label localFaceI = faceI - patches[patchI].start();
|
||||
fld[i] = sfld.boundaryField()[patchI][localFaceI];
|
||||
}
|
||||
}
|
||||
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::surfaceMeshWriter::write
|
||||
(
|
||||
const PtrList<GeometricField<Type, fvsPatchField, surfaceMesh> >& sflds
|
||||
)
|
||||
{
|
||||
forAll(sflds, fieldI)
|
||||
{
|
||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& fld =
|
||||
sflds[fieldI];
|
||||
|
||||
os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< pp_.size() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*pp_.size());
|
||||
writeFuns::insert(getFaceField(fld)(), fField);
|
||||
writeFuns::write(os_, binary_, fField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,82 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "vtkMesh.H"
|
||||
#include "fvMeshSubset.H"
|
||||
#include "Time.H"
|
||||
#include "cellSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vtkMesh::vtkMesh
|
||||
(
|
||||
fvMesh& baseMesh,
|
||||
const word& setName
|
||||
)
|
||||
:
|
||||
baseMesh_(baseMesh),
|
||||
subsetter_(baseMesh),
|
||||
setName_(setName)
|
||||
{
|
||||
if (setName.size())
|
||||
{
|
||||
// Read cellSet using whole mesh
|
||||
cellSet currentSet(baseMesh_, setName_);
|
||||
|
||||
// Set current subset
|
||||
subsetter_.setLargeCellSubset(currentSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate()
|
||||
{
|
||||
polyMesh::readUpdateState meshState = baseMesh_.readUpdate();
|
||||
|
||||
if (meshState != polyMesh::UNCHANGED)
|
||||
{
|
||||
// Note: since fvMeshSubset has no movePoints() functionality,
|
||||
// reconstruct the subset even if only movement.
|
||||
|
||||
topoPtr_.clear();
|
||||
|
||||
if (setName_.size())
|
||||
{
|
||||
Info<< "Subsetting mesh based on cellSet " << setName_ << endl;
|
||||
|
||||
// Read cellSet using whole mesh
|
||||
cellSet currentSet(baseMesh_, setName_);
|
||||
|
||||
subsetter_.setLargeCellSubset(currentSet);
|
||||
}
|
||||
}
|
||||
|
||||
return meshState;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,179 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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::vtkMesh
|
||||
|
||||
Description
|
||||
Encapsulation of VTK mesh data. Holds mesh or meshsubset and
|
||||
polyhedral-cell decomposition on it.
|
||||
|
||||
SourceFiles
|
||||
vtkMesh.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkMesh_H
|
||||
#define vtkMesh_H
|
||||
|
||||
#include "vtkTopo.H"
|
||||
#include "fvMeshSubset.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class Time;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class vtkMesh Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class vtkMesh
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference to mesh
|
||||
fvMesh& baseMesh_;
|
||||
|
||||
//- Subsetting engine + sub-fvMesh
|
||||
fvMeshSubset subsetter_;
|
||||
|
||||
//- Current cellSet (or empty)
|
||||
const word setName_;
|
||||
|
||||
//- Current decomposition of topology
|
||||
mutable autoPtr<vtkTopo> topoPtr_;
|
||||
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
vtkMesh(const vtkMesh&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const vtkMesh&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
vtkMesh(fvMesh& baseMesh, const word& setName = "");
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- whole mesh
|
||||
const fvMesh& baseMesh() const
|
||||
{
|
||||
return baseMesh_;
|
||||
}
|
||||
|
||||
const fvMeshSubset& subsetter() const
|
||||
{
|
||||
return subsetter_;
|
||||
}
|
||||
|
||||
//- Check if running subMesh
|
||||
bool useSubMesh() const
|
||||
{
|
||||
return setName_.size();
|
||||
}
|
||||
|
||||
//- topology
|
||||
const vtkTopo& topo() const
|
||||
{
|
||||
if (topoPtr_.empty())
|
||||
{
|
||||
topoPtr_.reset(new vtkTopo(mesh()));
|
||||
}
|
||||
return topoPtr_();
|
||||
}
|
||||
|
||||
//- Access either mesh or submesh
|
||||
const fvMesh& mesh() const
|
||||
{
|
||||
if (useSubMesh())
|
||||
{
|
||||
return subsetter_.subMesh();
|
||||
}
|
||||
else
|
||||
{
|
||||
return baseMesh_;
|
||||
}
|
||||
}
|
||||
|
||||
//- Number of field cells
|
||||
label nFieldCells() const
|
||||
{
|
||||
return topo().cellTypes().size();
|
||||
}
|
||||
|
||||
//- Number of field points
|
||||
label nFieldPoints() const
|
||||
{
|
||||
return mesh().nPoints() + topo().addPointCellLabels().size();
|
||||
}
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Read mesh
|
||||
polyMesh::readUpdateState readUpdate();
|
||||
|
||||
|
||||
//- Map volume field (does in fact do very little interpolation;
|
||||
// just copied from fvMeshSubset)
|
||||
template<class GeoField>
|
||||
tmp<GeoField> interpolate(const GeoField& fld) const
|
||||
{
|
||||
if (useSubMesh())
|
||||
{
|
||||
tmp<GeoField> subFld = subsetter_.interpolate(fld);
|
||||
subFld().rename(fld.name());
|
||||
return subFld;
|
||||
}
|
||||
else
|
||||
{
|
||||
return fld;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,373 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Description
|
||||
Note: bug in vtk displaying wedges? Seems to display ok if we decompose
|
||||
them. Should be thoroughly tested!
|
||||
(they appear rarely in polyhedral meshes, do appear in some cut meshes)
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkTopo.H"
|
||||
#include "polyMesh.H"
|
||||
#include "cellShape.H"
|
||||
#include "cellModeller.H"
|
||||
#include "Swap.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::vtkTopo::decomposePoly = true;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vtkTopo::vtkTopo(const polyMesh& mesh)
|
||||
:
|
||||
mesh_(mesh),
|
||||
vertLabels_(),
|
||||
cellTypes_(),
|
||||
addPointCellLabels_(),
|
||||
superCells_()
|
||||
{
|
||||
const cellModel& tet = *(cellModeller::lookup("tet"));
|
||||
const cellModel& pyr = *(cellModeller::lookup("pyr"));
|
||||
const cellModel& prism = *(cellModeller::lookup("prism"));
|
||||
const cellModel& wedge = *(cellModeller::lookup("wedge"));
|
||||
const cellModel& tetWedge = *(cellModeller::lookup("tetWedge"));
|
||||
const cellModel& hex = *(cellModeller::lookup("hex"));
|
||||
|
||||
const cellShapeList& cellShapes = mesh_.cellShapes();
|
||||
|
||||
// Number of additional points needed by the decomposition of polyhedra
|
||||
label nAddPoints = 0;
|
||||
|
||||
// Number of additional cells generated by the decomposition of polyhedra
|
||||
label nAddCells = 0;
|
||||
|
||||
// face owner is needed to determine the face orientation
|
||||
const labelList& owner = mesh.faceOwner();
|
||||
|
||||
// Scan for cells which need to be decomposed and count additional points
|
||||
// and cells
|
||||
if (decomposePoly)
|
||||
{
|
||||
forAll(cellShapes, cellI)
|
||||
{
|
||||
const cellModel& model = cellShapes[cellI].model();
|
||||
|
||||
if
|
||||
(
|
||||
model != hex
|
||||
&& model != wedge // See above.
|
||||
&& model != prism
|
||||
&& model != pyr
|
||||
&& model != tet
|
||||
&& model != tetWedge
|
||||
)
|
||||
{
|
||||
const cell& cFaces = mesh_.cells()[cellI];
|
||||
|
||||
forAll(cFaces, cFaceI)
|
||||
{
|
||||
const face& f = mesh_.faces()[cFaces[cFaceI]];
|
||||
|
||||
label nQuads = 0;
|
||||
label nTris = 0;
|
||||
f.nTrianglesQuads(mesh_.points(), nTris, nQuads);
|
||||
|
||||
nAddCells += nQuads + nTris;
|
||||
}
|
||||
|
||||
nAddCells--;
|
||||
nAddPoints++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set size of additional point addressing array
|
||||
// (from added point to original cell)
|
||||
addPointCellLabels_.setSize(nAddPoints);
|
||||
|
||||
// Set size of additional cells mapping array
|
||||
// (from added cell to original cell)
|
||||
superCells_.setSize(nAddCells);
|
||||
|
||||
// List of vertex labels in VTK ordering
|
||||
vertLabels_.setSize(cellShapes.size() + nAddCells);
|
||||
|
||||
// Label of vtk type
|
||||
cellTypes_.setSize(cellShapes.size() + nAddCells);
|
||||
|
||||
// Set counters for additional points and additional cells
|
||||
label addPointI = 0, addCellI = 0;
|
||||
|
||||
forAll(cellShapes, cellI)
|
||||
{
|
||||
const cellShape& cellShape = cellShapes[cellI];
|
||||
const cellModel& cellModel = cellShape.model();
|
||||
|
||||
labelList& vtkVerts = vertLabels_[cellI];
|
||||
|
||||
if (cellModel == tet)
|
||||
{
|
||||
vtkVerts = cellShape;
|
||||
|
||||
cellTypes_[cellI] = VTK_TETRA;
|
||||
}
|
||||
else if (cellModel == pyr)
|
||||
{
|
||||
vtkVerts = cellShape;
|
||||
|
||||
cellTypes_[cellI] = VTK_PYRAMID;
|
||||
}
|
||||
else if (cellModel == prism)
|
||||
{
|
||||
// VTK has a different node order for VTK_WEDGE
|
||||
// their triangles point outwards!
|
||||
vtkVerts = cellShape;
|
||||
|
||||
Foam::Swap(vtkVerts[1], vtkVerts[2]);
|
||||
Foam::Swap(vtkVerts[4], vtkVerts[5]);
|
||||
|
||||
cellTypes_[cellI] = VTK_WEDGE;
|
||||
}
|
||||
else if (cellModel == tetWedge)
|
||||
{
|
||||
// Treat as squeezed prism
|
||||
vtkVerts.setSize(6);
|
||||
vtkVerts[0] = cellShape[0];
|
||||
vtkVerts[1] = cellShape[2];
|
||||
vtkVerts[2] = cellShape[1];
|
||||
vtkVerts[3] = cellShape[3];
|
||||
vtkVerts[4] = cellShape[4];
|
||||
vtkVerts[5] = cellShape[4];
|
||||
|
||||
cellTypes_[cellI] = VTK_WEDGE;
|
||||
}
|
||||
else if (cellModel == wedge)
|
||||
{
|
||||
// Treat as squeezed hex
|
||||
vtkVerts.setSize(8);
|
||||
vtkVerts[0] = cellShape[0];
|
||||
vtkVerts[1] = cellShape[1];
|
||||
vtkVerts[2] = cellShape[2];
|
||||
vtkVerts[3] = cellShape[2];
|
||||
vtkVerts[4] = cellShape[3];
|
||||
vtkVerts[5] = cellShape[4];
|
||||
vtkVerts[6] = cellShape[5];
|
||||
vtkVerts[7] = cellShape[6];
|
||||
|
||||
cellTypes_[cellI] = VTK_HEXAHEDRON;
|
||||
}
|
||||
else if (cellModel == hex)
|
||||
{
|
||||
vtkVerts = cellShape;
|
||||
|
||||
cellTypes_[cellI] = VTK_HEXAHEDRON;
|
||||
}
|
||||
else if (decomposePoly)
|
||||
{
|
||||
// Polyhedral cell. Decompose into tets + pyramids.
|
||||
|
||||
// Mapping from additional point to cell
|
||||
addPointCellLabels_[addPointI] = cellI;
|
||||
|
||||
// The new vertex from the cell-centre
|
||||
const label newVertexLabel = mesh_.nPoints() + addPointI;
|
||||
|
||||
// Whether to insert cell in place of original or not.
|
||||
bool substituteCell = true;
|
||||
|
||||
const labelList& cFaces = mesh_.cells()[cellI];
|
||||
forAll(cFaces, cFaceI)
|
||||
{
|
||||
const face& f = mesh_.faces()[cFaces[cFaceI]];
|
||||
const bool isOwner = (owner[cFaces[cFaceI]] == cellI);
|
||||
|
||||
// Number of triangles and quads in decomposition
|
||||
label nTris = 0;
|
||||
label nQuads = 0;
|
||||
f.nTrianglesQuads(mesh_.points(), nTris, nQuads);
|
||||
|
||||
// Do actual decomposition into triFcs and quadFcs.
|
||||
faceList triFcs(nTris);
|
||||
faceList quadFcs(nQuads);
|
||||
label trii = 0;
|
||||
label quadi = 0;
|
||||
f.trianglesQuads(mesh_.points(), trii, quadi, triFcs, quadFcs);
|
||||
|
||||
forAll(quadFcs, quadI)
|
||||
{
|
||||
label thisCellI;
|
||||
|
||||
if (substituteCell)
|
||||
{
|
||||
thisCellI = cellI;
|
||||
substituteCell = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
thisCellI = mesh_.nCells() + addCellI;
|
||||
superCells_[addCellI++] = cellI;
|
||||
}
|
||||
|
||||
labelList& addVtkVerts = vertLabels_[thisCellI];
|
||||
|
||||
addVtkVerts.setSize(5);
|
||||
|
||||
const face& quad = quadFcs[quadI];
|
||||
|
||||
// Ensure we have the correct orientation for the
|
||||
// base of the primitive cell shape.
|
||||
// If the cell is face owner, the orientation needs to be
|
||||
// flipped.
|
||||
// At the moment, VTK doesn't actually seem to care if
|
||||
// negative cells are defined, but we'll do it anyhow
|
||||
// (for safety).
|
||||
if (isOwner)
|
||||
{
|
||||
addVtkVerts[0] = quad[3];
|
||||
addVtkVerts[1] = quad[2];
|
||||
addVtkVerts[2] = quad[1];
|
||||
addVtkVerts[3] = quad[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
addVtkVerts[0] = quad[0];
|
||||
addVtkVerts[1] = quad[1];
|
||||
addVtkVerts[2] = quad[2];
|
||||
addVtkVerts[3] = quad[3];
|
||||
}
|
||||
addVtkVerts[4] = newVertexLabel;
|
||||
|
||||
cellTypes_[thisCellI] = VTK_PYRAMID;
|
||||
}
|
||||
|
||||
forAll(triFcs, triI)
|
||||
{
|
||||
label thisCellI;
|
||||
|
||||
if (substituteCell)
|
||||
{
|
||||
thisCellI = cellI;
|
||||
substituteCell = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
thisCellI = mesh_.nCells() + addCellI;
|
||||
superCells_[addCellI++] = cellI;
|
||||
}
|
||||
|
||||
|
||||
labelList& addVtkVerts = vertLabels_[thisCellI];
|
||||
|
||||
const face& tri = triFcs[triI];
|
||||
|
||||
addVtkVerts.setSize(4);
|
||||
|
||||
// See note above about the orientation.
|
||||
if (isOwner)
|
||||
{
|
||||
addVtkVerts[0] = tri[2];
|
||||
addVtkVerts[1] = tri[1];
|
||||
addVtkVerts[2] = tri[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
addVtkVerts[0] = tri[0];
|
||||
addVtkVerts[1] = tri[1];
|
||||
addVtkVerts[2] = tri[2];
|
||||
}
|
||||
addVtkVerts[3] = newVertexLabel;
|
||||
|
||||
cellTypes_[thisCellI] = VTK_TETRA;
|
||||
}
|
||||
}
|
||||
|
||||
addPointI++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Polyhedral cell - not decomposed
|
||||
cellTypes_[cellI] = VTK_POLYHEDRON;
|
||||
|
||||
const labelList& cFaces = mesh_.cells()[cellI];
|
||||
|
||||
// space for the number of faces and size of each face
|
||||
label nData = 1 + cFaces.size();
|
||||
|
||||
// count total number of face points
|
||||
forAll(cFaces, cFaceI)
|
||||
{
|
||||
const face& f = mesh.faces()[cFaces[cFaceI]];
|
||||
nData += f.size(); // space for the face labels
|
||||
}
|
||||
|
||||
vtkVerts.setSize(nData);
|
||||
|
||||
nData = 0;
|
||||
vtkVerts[nData++] = cFaces.size();
|
||||
|
||||
// build face stream
|
||||
forAll(cFaces, cFaceI)
|
||||
{
|
||||
const face& f = mesh.faces()[cFaces[cFaceI]];
|
||||
const bool isOwner = (owner[cFaces[cFaceI]] == cellI);
|
||||
|
||||
// number of labels for this face
|
||||
vtkVerts[nData++] = f.size();
|
||||
|
||||
if (isOwner)
|
||||
{
|
||||
forAll(f, fp)
|
||||
{
|
||||
vtkVerts[nData++] = f[fp];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// fairly immaterial if we reverse the list
|
||||
// or use face::reverseFace()
|
||||
forAllReverse(f, fp)
|
||||
{
|
||||
vtkVerts[nData++] = f[fp];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (decomposePoly)
|
||||
{
|
||||
Pout<< " Original cells:" << mesh_.nCells()
|
||||
<< " points:" << mesh_.nPoints()
|
||||
<< " Additional cells:" << superCells_.size()
|
||||
<< " additional points:" << addPointCellLabels_.size()
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,139 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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::vtkTopo
|
||||
|
||||
Description
|
||||
Polyhedral cell decomposition for VTK.
|
||||
|
||||
SourceFiles
|
||||
vtkTopo.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkTopo_H
|
||||
#define vtkTopo_H
|
||||
|
||||
#include "labelList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class polyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class vtkTopo Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class vtkTopo
|
||||
{
|
||||
// Private data
|
||||
|
||||
const polyMesh& mesh_;
|
||||
|
||||
//- Vertices per cell (including added cells) in vtk ordering
|
||||
labelListList vertLabels_;
|
||||
|
||||
//- Cell types (including added cells) in vtk numbering
|
||||
labelList cellTypes_;
|
||||
|
||||
labelList addPointCellLabels_;
|
||||
|
||||
labelList superCells_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
vtkTopo(const vtkTopo&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const vtkTopo&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Public static data
|
||||
|
||||
//- equivalent to enumeration in "vtkCellType.h"
|
||||
enum vtkTypes
|
||||
{
|
||||
VTK_TRIANGLE = 5,
|
||||
VTK_POLYGON = 7,
|
||||
VTK_QUAD = 9,
|
||||
|
||||
VTK_TETRA = 10,
|
||||
VTK_HEXAHEDRON = 12,
|
||||
VTK_WEDGE = 13,
|
||||
VTK_PYRAMID = 14,
|
||||
VTK_POLYHEDRON = 42
|
||||
};
|
||||
|
||||
//- Enable/disable polyhedron decomposition. Default = true
|
||||
static bool decomposePoly;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
vtkTopo(const polyMesh&);
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
const labelListList& vertLabels() const
|
||||
{
|
||||
return vertLabels_;
|
||||
}
|
||||
|
||||
const labelList& cellTypes() const
|
||||
{
|
||||
return cellTypes_;
|
||||
}
|
||||
|
||||
const labelList& addPointCellLabels() const
|
||||
{
|
||||
return addPointCellLabels_;
|
||||
}
|
||||
|
||||
const labelList& superCells() const
|
||||
{
|
||||
return superCells_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,127 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "writeFaceSet.H"
|
||||
#include "OFstream.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::writeFaceSet
|
||||
(
|
||||
const bool binary,
|
||||
const vtkMesh& vMesh,
|
||||
const faceSet& set,
|
||||
const fileName& fileName
|
||||
)
|
||||
{
|
||||
const faceList& faces = vMesh.mesh().faces();
|
||||
|
||||
std::ofstream ostr(fileName.c_str());
|
||||
|
||||
writeFuns::writeHeader
|
||||
(
|
||||
ostr,
|
||||
binary,
|
||||
set.name()
|
||||
);
|
||||
|
||||
ostr<< "DATASET POLYDATA" << std::endl;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Write topology
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
||||
// Construct primitivePatch of faces in faceSet.
|
||||
|
||||
faceList setFaces(set.size());
|
||||
labelList setFaceLabels(set.size());
|
||||
label setFaceI = 0;
|
||||
|
||||
forAllConstIter(faceSet, set, iter)
|
||||
{
|
||||
setFaceLabels[setFaceI] = iter.key();
|
||||
setFaces[setFaceI] = faces[iter.key()];
|
||||
setFaceI++;
|
||||
}
|
||||
primitiveFacePatch fp(setFaces, vMesh.mesh().points());
|
||||
|
||||
|
||||
// Write points and faces as polygons
|
||||
|
||||
ostr<< "POINTS " << fp.nPoints() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> ptField(3*fp.nPoints());
|
||||
|
||||
writeFuns::insert(fp.localPoints(), ptField);
|
||||
|
||||
writeFuns::write(ostr, binary, ptField);
|
||||
|
||||
|
||||
label nFaceVerts = 0;
|
||||
|
||||
forAll(fp.localFaces(), faceI)
|
||||
{
|
||||
nFaceVerts += fp.localFaces()[faceI].size() + 1;
|
||||
}
|
||||
ostr<< "POLYGONS " << fp.size() << ' ' << nFaceVerts << std::endl;
|
||||
|
||||
|
||||
DynamicList<label> vertLabels(nFaceVerts);
|
||||
|
||||
forAll(fp.localFaces(), faceI)
|
||||
{
|
||||
const face& f = fp.localFaces()[faceI];
|
||||
|
||||
vertLabels.append(f.size());
|
||||
|
||||
writeFuns::insert(f, vertLabels);
|
||||
}
|
||||
writeFuns::write(ostr, binary, vertLabels);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
//
|
||||
// Write data
|
||||
//
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
// Write faceID
|
||||
|
||||
ostr
|
||||
<< "CELL_DATA " << fp.size() << std::endl
|
||||
<< "FIELD attributes 1" << std::endl;
|
||||
|
||||
// Cell ids first
|
||||
ostr<< "faceID 1 " << fp.size() << " int" << std::endl;
|
||||
|
||||
writeFuns::write(ostr, binary, setFaceLabels);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,63 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InClass
|
||||
Foam::writeFaceSet
|
||||
|
||||
Description
|
||||
Write faceSet to vtk polydata file. Only one data which is original
|
||||
faceID.
|
||||
|
||||
SourceFiles
|
||||
writeFaceSet.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writeFaceSet_H
|
||||
#define writeFaceSet_H
|
||||
|
||||
#include "vtkMesh.H"
|
||||
#include "faceSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Write lagrangian fields.
|
||||
void writeFaceSet
|
||||
(
|
||||
const bool binary,
|
||||
const vtkMesh& vMesh,
|
||||
const faceSet& set,
|
||||
const fileName& fileName
|
||||
);
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,288 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "writeFuns.H"
|
||||
#include "vtkTopo.H"
|
||||
|
||||
#if defined(__mips) && !defined(__SICORTEX__)
|
||||
#include <standards.h>
|
||||
#include <sys/endian.h>
|
||||
#endif
|
||||
|
||||
// MacOSX
|
||||
#ifdef __DARWIN_BYTE_ORDER
|
||||
#if __DARWIN_BYTE_ORDER==__DARWIN_BIG_ENDIAN
|
||||
#undef LITTLE_ENDIAN
|
||||
#else
|
||||
#undef BIG_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LITTLE_ENDIAN) \
|
||||
|| defined(_LITTLE_ENDIAN) \
|
||||
|| defined(__LITTLE_ENDIAN)
|
||||
# define LITTLEENDIAN 1
|
||||
#elif defined(BIG_ENDIAN) || defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN)
|
||||
# undef LITTLEENDIAN
|
||||
#else
|
||||
# error "Cannot find LITTLE_ENDIAN or BIG_ENDIAN symbol defined."
|
||||
# error "Please add to compilation options"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::writeFuns::swapWord(label& word32)
|
||||
{
|
||||
char* mem = reinterpret_cast<char*>(&word32);
|
||||
|
||||
char a = mem[0];
|
||||
mem[0] = mem[3];
|
||||
mem[3] = a;
|
||||
|
||||
a = mem[1];
|
||||
mem[1] = mem[2];
|
||||
mem[2] = a;
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::swapWords(const label nWords, label* words32)
|
||||
{
|
||||
for (label i = 0; i < nWords; i++)
|
||||
{
|
||||
swapWord(words32[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::write
|
||||
(
|
||||
std::ostream& os,
|
||||
const bool binary,
|
||||
List<floatScalar>& fField
|
||||
)
|
||||
{
|
||||
if (binary)
|
||||
{
|
||||
# ifdef LITTLEENDIAN
|
||||
swapWords(fField.size(), reinterpret_cast<label*>(fField.begin()));
|
||||
# endif
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<char*>(fField.begin()),
|
||||
fField.size()*sizeof(float)
|
||||
);
|
||||
|
||||
os << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(fField, i)
|
||||
{
|
||||
os << fField[i];
|
||||
|
||||
if (i > 0 && (i % 10) == 0)
|
||||
{
|
||||
os << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::write
|
||||
(
|
||||
std::ostream& os,
|
||||
const bool binary,
|
||||
DynamicList<floatScalar>& fField
|
||||
)
|
||||
{
|
||||
List<floatScalar>& fld = fField.shrink();
|
||||
|
||||
write(os, binary, fld);
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::write
|
||||
(
|
||||
std::ostream& os,
|
||||
const bool binary,
|
||||
labelList& elems
|
||||
)
|
||||
{
|
||||
if (binary)
|
||||
{
|
||||
# ifdef LITTLEENDIAN
|
||||
swapWords(elems.size(), reinterpret_cast<label*>(elems.begin()));
|
||||
# endif
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<char*>(elems.begin()),
|
||||
elems.size()*sizeof(label)
|
||||
);
|
||||
|
||||
os << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(elems, i)
|
||||
{
|
||||
os << elems[i];
|
||||
|
||||
if (i > 0 && (i % 10) == 0)
|
||||
{
|
||||
os << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::write
|
||||
(
|
||||
std::ostream& os,
|
||||
const bool binary,
|
||||
DynamicList<label>& elems
|
||||
)
|
||||
{
|
||||
labelList& fld = elems.shrink();
|
||||
|
||||
write(os, binary, fld);
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::writeHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const bool binary,
|
||||
const std::string& title
|
||||
)
|
||||
{
|
||||
os << "# vtk DataFile Version 2.0" << std::endl
|
||||
<< title << std::endl;
|
||||
|
||||
if (binary)
|
||||
{
|
||||
os << "BINARY" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "ASCII" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::writeCellDataHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const label nCells,
|
||||
const label nFields
|
||||
)
|
||||
{
|
||||
os << "CELL_DATA " << nCells << std::endl
|
||||
<< "FIELD attributes " << nFields << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::writePointDataHeader
|
||||
(
|
||||
std::ostream& os,
|
||||
const label nPoints,
|
||||
const label nFields
|
||||
)
|
||||
{
|
||||
os << "POINT_DATA " << nPoints << std::endl
|
||||
<< "FIELD attributes " << nFields << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::insert(const scalar src, DynamicList<floatScalar>& dest)
|
||||
{
|
||||
dest.append(float(src));
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::insert(const vector& src, DynamicList<floatScalar>& dest)
|
||||
{
|
||||
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
|
||||
{
|
||||
dest.append(float(src[cmpt]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::insert
|
||||
(
|
||||
const sphericalTensor& src,
|
||||
DynamicList<floatScalar>& dest
|
||||
)
|
||||
{
|
||||
for (direction cmpt = 0; cmpt < sphericalTensor::nComponents; ++cmpt)
|
||||
{
|
||||
dest.append(float(src[cmpt]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::insert
|
||||
(
|
||||
const symmTensor& src,
|
||||
DynamicList<floatScalar>& dest
|
||||
)
|
||||
{
|
||||
dest.append(float(src.xx()));
|
||||
dest.append(float(src.yy()));
|
||||
dest.append(float(src.zz()));
|
||||
dest.append(float(src.xy()));
|
||||
dest.append(float(src.yz()));
|
||||
dest.append(float(src.xz()));
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::insert(const tensor& src, DynamicList<floatScalar>& dest)
|
||||
{
|
||||
for (direction cmpt = 0; cmpt < tensor::nComponents; ++cmpt)
|
||||
{
|
||||
dest.append(float(src[cmpt]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeFuns::insert(const labelList& src, DynamicList<label>& dest)
|
||||
{
|
||||
dest.append(src);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,180 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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::writeFuns
|
||||
|
||||
Description
|
||||
Various functions for collecting and writing binary data.
|
||||
|
||||
SourceFiles
|
||||
writeFuns.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writeFuns_H
|
||||
#define writeFuns_H
|
||||
|
||||
#include "floatScalar.H"
|
||||
#include "DynamicList.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "pointFieldsFwd.H"
|
||||
#include "vtkMesh.H"
|
||||
#include "volPointInterpolation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class writeFuns Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class writeFuns
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
// Swap halves of word.
|
||||
|
||||
static void swapWord(label& word32);
|
||||
static void swapWords(const label nWords, label* words32);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Write ascii or binary. If binary optionally in-place swaps argument
|
||||
|
||||
static void write(std::ostream&, const bool, List<floatScalar>&);
|
||||
static void write(std::ostream&, const bool, DynamicList<floatScalar>&);
|
||||
static void write(std::ostream&, const bool, labelList&);
|
||||
static void write(std::ostream&, const bool, DynamicList<label>&);
|
||||
|
||||
|
||||
// Write header
|
||||
|
||||
static void writeHeader
|
||||
(
|
||||
std::ostream&,
|
||||
const bool isBinary,
|
||||
const std::string& title
|
||||
);
|
||||
static void writeCellDataHeader
|
||||
(
|
||||
std::ostream&,
|
||||
const label nCells,
|
||||
const label nFields
|
||||
);
|
||||
static void writePointDataHeader
|
||||
(
|
||||
std::ostream&,
|
||||
const label nPoints,
|
||||
const label nFields
|
||||
);
|
||||
|
||||
|
||||
// Convert to VTK and store
|
||||
|
||||
static void insert(const scalar, DynamicList<floatScalar>&);
|
||||
static void insert(const point&, DynamicList<floatScalar>&);
|
||||
static void insert(const sphericalTensor&, DynamicList<floatScalar>&);
|
||||
static void insert(const symmTensor&, DynamicList<floatScalar>&);
|
||||
static void insert(const tensor&, DynamicList<floatScalar>&);
|
||||
|
||||
|
||||
//- Append elements to DynamicList
|
||||
static void insert(const labelList&, DynamicList<label>&);
|
||||
template<class Type>
|
||||
static void insert(const List<Type>&, DynamicList<floatScalar>&);
|
||||
|
||||
//- Write volField with cell values (including decomposed cells)
|
||||
template<class Type>
|
||||
static void write
|
||||
(
|
||||
std::ostream&,
|
||||
const bool binary,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
const vtkMesh&
|
||||
);
|
||||
|
||||
//- Write pointField on all mesh points. Interpolate to cell centre
|
||||
// for decomposed cell centres.
|
||||
template<class Type>
|
||||
static void write
|
||||
(
|
||||
std::ostream&,
|
||||
const bool binary,
|
||||
const GeometricField<Type, pointPatchField, pointMesh>&,
|
||||
const vtkMesh&
|
||||
);
|
||||
|
||||
//- Write interpolated field on points and original cell values on
|
||||
// decomposed cell centres.
|
||||
template<class Type>
|
||||
static void write
|
||||
(
|
||||
std::ostream&,
|
||||
const bool binary,
|
||||
const GeometricField<Type, fvPatchField, volMesh>&,
|
||||
const GeometricField<Type, pointPatchField, pointMesh>&,
|
||||
const vtkMesh&
|
||||
);
|
||||
|
||||
//- Write generic GeometricFields
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
static void write
|
||||
(
|
||||
std::ostream&,
|
||||
const bool binary,
|
||||
const PtrList<GeometricField<Type, PatchField, GeoMesh> >&,
|
||||
const vtkMesh&
|
||||
);
|
||||
|
||||
//- Interpolate and write volFields
|
||||
template<class Type>
|
||||
static void write
|
||||
(
|
||||
std::ostream&,
|
||||
const bool binary,
|
||||
const volPointInterpolation&,
|
||||
const PtrList<GeometricField<Type, fvPatchField, volMesh> >&,
|
||||
const vtkMesh&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "writeFunsTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,192 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "writeFuns.H"
|
||||
#include "interpolatePointToCell.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Store List in dest
|
||||
template<class Type>
|
||||
void Foam::writeFuns::insert
|
||||
(
|
||||
const List<Type>& source,
|
||||
DynamicList<floatScalar>& dest
|
||||
)
|
||||
{
|
||||
forAll(source, i)
|
||||
{
|
||||
insert(source[i], dest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// Store List (indexed through map) in dest
|
||||
//template<class Type>
|
||||
//void Foam::writeFuns::insert
|
||||
//(
|
||||
// const labelList& map,
|
||||
// const List<Type>& source,
|
||||
// DynamicList<floatScalar>& dest
|
||||
//)
|
||||
//{
|
||||
// forAll(map, i)
|
||||
// {
|
||||
// insert(source[map[i]], dest);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::writeFuns::write
|
||||
(
|
||||
std::ostream& os,
|
||||
const bool binary,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vvf,
|
||||
const vtkMesh& vMesh
|
||||
)
|
||||
{
|
||||
const fvMesh& mesh = vMesh.mesh();
|
||||
|
||||
const labelList& superCells = vMesh.topo().superCells();
|
||||
|
||||
label nValues = mesh.nCells() + superCells.size();
|
||||
|
||||
os << vvf.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< nValues << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nValues);
|
||||
|
||||
insert(vvf.internalField(), fField);
|
||||
|
||||
forAll(superCells, superCellI)
|
||||
{
|
||||
label origCellI = superCells[superCellI];
|
||||
|
||||
insert(vvf[origCellI], fField);
|
||||
}
|
||||
write(os, binary, fField);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::writeFuns::write
|
||||
(
|
||||
std::ostream& os,
|
||||
const bool binary,
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& pvf,
|
||||
const vtkMesh& vMesh
|
||||
)
|
||||
{
|
||||
const fvMesh& mesh = vMesh.mesh();
|
||||
const vtkTopo& topo = vMesh.topo();
|
||||
|
||||
const labelList& addPointCellLabels = topo.addPointCellLabels();
|
||||
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
|
||||
|
||||
os << pvf.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< nTotPoints << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
|
||||
|
||||
insert(pvf, fField);
|
||||
|
||||
forAll(addPointCellLabels, api)
|
||||
{
|
||||
label origCellI = addPointCellLabels[api];
|
||||
|
||||
insert(interpolatePointToCell(pvf, origCellI), fField);
|
||||
}
|
||||
write(os, binary, fField);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::writeFuns::write
|
||||
(
|
||||
std::ostream& os,
|
||||
const bool binary,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vvf,
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& pvf,
|
||||
const vtkMesh& vMesh
|
||||
)
|
||||
{
|
||||
const fvMesh& mesh = vMesh.mesh();
|
||||
const vtkTopo& topo = vMesh.topo();
|
||||
|
||||
const labelList& addPointCellLabels = topo.addPointCellLabels();
|
||||
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
|
||||
|
||||
os << vvf.name() << ' ' << pTraits<Type>::nComponents << ' '
|
||||
<< nTotPoints << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
|
||||
|
||||
insert(pvf, fField);
|
||||
|
||||
forAll(addPointCellLabels, api)
|
||||
{
|
||||
label origCellI = addPointCellLabels[api];
|
||||
|
||||
insert(vvf[origCellI], fField);
|
||||
}
|
||||
write(os, binary, fField);
|
||||
}
|
||||
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::writeFuns::write
|
||||
(
|
||||
std::ostream& os,
|
||||
const bool binary,
|
||||
const PtrList<GeometricField<Type, PatchField, GeoMesh> >& flds,
|
||||
const vtkMesh& vMesh
|
||||
)
|
||||
{
|
||||
forAll(flds, i)
|
||||
{
|
||||
write(os, binary, flds[i], vMesh);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::writeFuns::write
|
||||
(
|
||||
std::ostream& os,
|
||||
const bool binary,
|
||||
const volPointInterpolation& pInterp,
|
||||
const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds,
|
||||
const vtkMesh& vMesh
|
||||
)
|
||||
{
|
||||
forAll(flds, i)
|
||||
{
|
||||
write(os, binary, flds[i], pInterp.interpolate(flds[i])(), vMesh);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,103 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "writePointSet.H"
|
||||
#include "OFstream.H"
|
||||
#include "writeFuns.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
void writePointSet
|
||||
(
|
||||
const bool binary,
|
||||
const vtkMesh& vMesh,
|
||||
const pointSet& set,
|
||||
const fileName& fileName
|
||||
)
|
||||
{
|
||||
std::ofstream ostr(fileName.c_str());
|
||||
|
||||
writeFuns::writeHeader
|
||||
(
|
||||
ostr,
|
||||
binary,
|
||||
set.name()
|
||||
);
|
||||
|
||||
ostr<< "DATASET POLYDATA" << std::endl;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Write topology
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
||||
// Write points
|
||||
|
||||
ostr<< "POINTS " << set.size() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> ptField(3*set.size());
|
||||
|
||||
writeFuns::insert
|
||||
(
|
||||
UIndirectList<point>(vMesh.mesh().points(), set.toc())(),
|
||||
ptField
|
||||
);
|
||||
|
||||
writeFuns::write(ostr, binary, ptField);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
//
|
||||
// Write data
|
||||
//
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
// Write faceID
|
||||
|
||||
ostr
|
||||
<< "POINT_DATA " << set.size() << std::endl
|
||||
<< "FIELD attributes 1" << std::endl;
|
||||
|
||||
// Cell ids first
|
||||
ostr<< "pointID 1 " << set.size() << " int" << std::endl;
|
||||
|
||||
labelList pointIDs(set.toc());
|
||||
|
||||
writeFuns::write(ostr, binary, pointIDs);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,63 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InClass
|
||||
Foam::writePointSet
|
||||
|
||||
Description
|
||||
Write pointSet to vtk polydata file. Only one data which is original
|
||||
pointID.
|
||||
|
||||
SourceFiles
|
||||
writePointSet.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writePointSet_H
|
||||
#define writePointSet_H
|
||||
|
||||
#include "vtkMesh.H"
|
||||
#include "pointSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Write lagrangian fields.
|
||||
void writePointSet
|
||||
(
|
||||
const bool binary,
|
||||
const vtkMesh& vMesh,
|
||||
const pointSet& set,
|
||||
const fileName& fileName
|
||||
);
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,124 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 "writeSurfFields.H"
|
||||
#include "OFstream.H"
|
||||
#include "floatScalar.H"
|
||||
#include "writeFuns.H"
|
||||
#include "emptyFvsPatchFields.H"
|
||||
#include "fvsPatchFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
void writeSurfFields
|
||||
(
|
||||
const bool binary,
|
||||
const vtkMesh& vMesh,
|
||||
const fileName& fileName,
|
||||
const PtrList<surfaceVectorField>& surfVectorFields
|
||||
)
|
||||
{
|
||||
const fvMesh& mesh = vMesh.mesh();
|
||||
|
||||
std::ofstream str(fileName.c_str());
|
||||
|
||||
writeFuns::writeHeader
|
||||
(
|
||||
str,
|
||||
binary,
|
||||
"surfaceFields"
|
||||
);
|
||||
|
||||
str << "DATASET POLYDATA" << std::endl;
|
||||
|
||||
const pointField& fc = mesh.faceCentres();
|
||||
|
||||
str << "POINTS " << mesh.nFaces() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> pField(3*mesh.nFaces());
|
||||
|
||||
for (label faceI = 0; faceI < mesh.nFaces(); faceI++)
|
||||
{
|
||||
writeFuns::insert(fc[faceI], pField);
|
||||
}
|
||||
|
||||
writeFuns::write(str, binary, pField);
|
||||
|
||||
str << "POINT_DATA " << mesh.nFaces() << std::endl
|
||||
<< "FIELD attributes " << surfVectorFields.size() << std::endl;
|
||||
|
||||
// surfVectorFields
|
||||
forAll(surfVectorFields, fieldI)
|
||||
{
|
||||
const surfaceVectorField& svf = surfVectorFields[fieldI];
|
||||
|
||||
str << svf.name() << " 3 "
|
||||
<< mesh.nFaces() << " float" << std::endl;
|
||||
|
||||
DynamicList<floatScalar> fField(3*mesh.nFaces());
|
||||
|
||||
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
|
||||
{
|
||||
writeFuns::insert(svf[faceI], fField);
|
||||
}
|
||||
|
||||
forAll(svf.boundaryField(), patchI)
|
||||
{
|
||||
const fvsPatchVectorField& pf = svf.boundaryField()[patchI];
|
||||
|
||||
const fvPatch& pp = mesh.boundary()[patchI];
|
||||
|
||||
if (isA<emptyFvsPatchVectorField>(pf))
|
||||
{
|
||||
// Note: loop over polypatch size, not fvpatch size.
|
||||
forAll(pp.patch(), i)
|
||||
{
|
||||
writeFuns::insert(vector::zero, fField);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(pf, i)
|
||||
{
|
||||
writeFuns::insert(pf[i], fField);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writeFuns::write(str, binary, fField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,63 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
InClass
|
||||
Foam::writeSurfFields
|
||||
|
||||
Description
|
||||
Write a patch with its data.
|
||||
|
||||
SourceFiles
|
||||
writeSurfFields.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writeSurfFields_H
|
||||
#define writeSurfFields_H
|
||||
|
||||
#include "vtkMesh.H"
|
||||
#include "surfaceMesh.H"
|
||||
#include "surfaceFieldsFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Write surface vector fields
|
||||
void writeSurfFields
|
||||
(
|
||||
const bool binary,
|
||||
const vtkMesh& vMesh,
|
||||
const fileName& fileName,
|
||||
const PtrList<surfaceVectorField>& surfVectorFields
|
||||
);
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,3 @@
|
||||
smapToFoam.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/smapToFoam
|
||||
@ -0,0 +1,6 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lgenericPatchFields \
|
||||
-lfiniteVolume
|
||||
@ -0,0 +1,243 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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/>.
|
||||
|
||||
Application
|
||||
smapToFoam
|
||||
|
||||
Description
|
||||
Translates a STAR-CD SMAP data file into OpenFOAM field format.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.append("SMAP fileName");
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
if (!args.check())
|
||||
{
|
||||
FatalError.exit();
|
||||
}
|
||||
|
||||
# include "createTime.H"
|
||||
|
||||
fileNameList fieldNames = readDir(runTime.timePath(), fileName::FILE);
|
||||
dictionary fieldNameDict;
|
||||
forAll(fieldNames, i)
|
||||
{
|
||||
fieldNameDict.add(fieldNames[i], word(fieldNames[i]));
|
||||
}
|
||||
|
||||
dictionary nameMap;
|
||||
if (fieldNameDict.found("U")) nameMap.add("SU", word("U"));
|
||||
if (fieldNameDict.found("p")) nameMap.add("P", word("p"));
|
||||
if (fieldNameDict.found("T")) nameMap.add("T", word("T"));
|
||||
if (fieldNameDict.found("rho")) nameMap.add("DENS", word("rho"));
|
||||
if (fieldNameDict.found("k")) nameMap.add("TE", word("k"));
|
||||
if (fieldNameDict.found("epsilon")) nameMap.add("ED", word("epsilon"));
|
||||
if (fieldNameDict.found("nuEff")) nameMap.add("VIS", word("nuEff"));
|
||||
|
||||
# include "createMesh.H"
|
||||
|
||||
IFstream smapFile(args[1]);
|
||||
|
||||
if (!smapFile.good())
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Cannot open SMAP file " << smapFile.name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
while (!smapFile.eof())
|
||||
{
|
||||
wordList starFieldNames(10);
|
||||
|
||||
token fieldName(smapFile);
|
||||
|
||||
if (!smapFile.good())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
fieldName.type() != token::WORD
|
||||
&& fieldName.wordToken() != "CELL"
|
||||
)
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Expected first CELL, found "
|
||||
<< fieldName
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
label nCols = 0;
|
||||
smapFile >> fieldName;
|
||||
while (fieldName.type() == token::WORD)
|
||||
{
|
||||
starFieldNames[nCols++] = fieldName.wordToken();
|
||||
smapFile >> fieldName;
|
||||
}
|
||||
|
||||
List<volScalarField*> sFields
|
||||
(
|
||||
nCols,
|
||||
reinterpret_cast<volScalarField*>(0)
|
||||
);
|
||||
|
||||
List<volVectorField*> vFields
|
||||
(
|
||||
nCols,
|
||||
reinterpret_cast<volVectorField*>(0)
|
||||
);
|
||||
|
||||
label i=0;
|
||||
while (i < nCols)
|
||||
{
|
||||
if (nameMap.found(starFieldNames[i]))
|
||||
{
|
||||
if (starFieldNames[i] == "SU")
|
||||
{
|
||||
vFields[i] =
|
||||
new volVectorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
nameMap.lookup(starFieldNames[i]),
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
i += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
sFields[i] =
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
nameMap.lookup(starFieldNames[i]),
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
label cell;
|
||||
scalar value;
|
||||
forAll(mesh.cells(), celli)
|
||||
{
|
||||
if (celli > 0)
|
||||
{
|
||||
smapFile >> cell;
|
||||
}
|
||||
|
||||
label i=0;
|
||||
while (i < nCols)
|
||||
{
|
||||
if (sFields[i])
|
||||
{
|
||||
smapFile >> (*sFields[i])[celli];
|
||||
i++;
|
||||
}
|
||||
else if (vFields[i])
|
||||
{
|
||||
smapFile >> (*vFields[i])[celli].x();
|
||||
smapFile >> (*vFields[i])[celli].y();
|
||||
smapFile >> (*vFields[i])[celli].z();
|
||||
i += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
smapFile >> value;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (label i=0; i<nCols; i++)
|
||||
{
|
||||
if (sFields[i])
|
||||
{
|
||||
sFields[i]->correctBoundaryConditions();
|
||||
sFields[i]->write();
|
||||
delete sFields[i];
|
||||
sFields[i] = NULL;
|
||||
}
|
||||
else if (vFields[i])
|
||||
{
|
||||
vFields[i]->correctBoundaryConditions();
|
||||
vFields[i]->write();
|
||||
delete vFields[i];
|
||||
vFields[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Read dummy entry and check the cell index
|
||||
smapFile >> cell;
|
||||
|
||||
if (cell != 0)
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Expected first SMAP dummy entry to be cell 0, found "
|
||||
<< cell
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
for (label i=0; i<nCols; i++)
|
||||
{
|
||||
smapFile >> value;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user