mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Updates to set and surface writers
- New boundaryData surface writer - Moved templated code into separate files - Output filenames written to functionObjectState dictionary - Ensight surface writer now supports a 'collate times' option [mattijs] - Nastran surface writer updated based on user feedback
This commit is contained in:
@ -50,6 +50,7 @@ $(surfWriters)/proxy/proxySurfaceWriter.C
|
|||||||
$(surfWriters)/raw/rawSurfaceWriter.C
|
$(surfWriters)/raw/rawSurfaceWriter.C
|
||||||
$(surfWriters)/starcd/starcdSurfaceWriter.C
|
$(surfWriters)/starcd/starcdSurfaceWriter.C
|
||||||
$(surfWriters)/vtk/vtkSurfaceWriter.C
|
$(surfWriters)/vtk/vtkSurfaceWriter.C
|
||||||
|
$(surfWriters)/boundaryData/boundaryDataSurfaceWriter.C
|
||||||
|
|
||||||
graphField/writePatchGraph.C
|
graphField/writePatchGraph.C
|
||||||
graphField/writeCellGraph.C
|
graphField/writeCellGraph.C
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -136,8 +136,8 @@ Foam::sampledSets::sampledSets
|
|||||||
const bool loadFromFiles
|
const bool loadFromFiles
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
|
functionObjectState(obr, name),
|
||||||
PtrList<sampledSet>(),
|
PtrList<sampledSet>(),
|
||||||
name_(name),
|
|
||||||
mesh_(refCast<const fvMesh>(obr)),
|
mesh_(refCast<const fvMesh>(obr)),
|
||||||
loadFromFiles_(loadFromFiles),
|
loadFromFiles_(loadFromFiles),
|
||||||
outputPath_(fileName::null),
|
outputPath_(fileName::null),
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -36,6 +36,7 @@ SourceFiles
|
|||||||
#ifndef sampledSets_H
|
#ifndef sampledSets_H
|
||||||
#define sampledSets_H
|
#define sampledSets_H
|
||||||
|
|
||||||
|
#include "functionObjectState.H"
|
||||||
#include "sampledSet.H"
|
#include "sampledSet.H"
|
||||||
#include "volFieldsFwd.H"
|
#include "volFieldsFwd.H"
|
||||||
#include "meshSearch.H"
|
#include "meshSearch.H"
|
||||||
@ -59,6 +60,7 @@ class fvMesh;
|
|||||||
|
|
||||||
class sampledSets
|
class sampledSets
|
||||||
:
|
:
|
||||||
|
public functionObjectState,
|
||||||
public PtrList<sampledSet>
|
public PtrList<sampledSet>
|
||||||
{
|
{
|
||||||
// Private classes
|
// Private classes
|
||||||
@ -153,10 +155,6 @@ class sampledSets
|
|||||||
|
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Name of this set of sets,
|
|
||||||
// Also used as the name of the sampledSets directory.
|
|
||||||
word name_;
|
|
||||||
|
|
||||||
//- Const reference to fvMesh
|
//- Const reference to fvMesh
|
||||||
const fvMesh& mesh_;
|
const fvMesh& mesh_;
|
||||||
|
|
||||||
@ -273,12 +271,6 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return name of the set of probes
|
|
||||||
virtual const word& name() const
|
|
||||||
{
|
|
||||||
return name_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Set verbosity level
|
//- Set verbosity level
|
||||||
void verbose(const bool verbosity = true);
|
void verbose(const bool verbosity = true);
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -155,6 +155,14 @@ void Foam::sampledSets::writeSampleFile
|
|||||||
valueSets,
|
valueSets,
|
||||||
ofs
|
ofs
|
||||||
);
|
);
|
||||||
|
|
||||||
|
forAll(masterFields, fieldi)
|
||||||
|
{
|
||||||
|
dictionary propsDict;
|
||||||
|
propsDict.add("file", fName);
|
||||||
|
const word& fieldName = masterFields[fieldi].name();
|
||||||
|
setProperty(fieldName, propsDict);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -226,10 +234,7 @@ void Foam::sampledSets::combineSampledValues
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::sampledSets::sampleAndWrite
|
void Foam::sampledSets::sampleAndWrite(fieldGroup<Type>& fields)
|
||||||
(
|
|
||||||
fieldGroup<Type>& fields
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (fields.size())
|
if (fields.size())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -49,7 +49,7 @@ void Foam::sampledSurfaces::writeGeometry() const
|
|||||||
// Write to time directory under outputPath_
|
// Write to time directory under outputPath_
|
||||||
// Skip surface without faces (eg, a failed cut-plane)
|
// Skip surface without faces (eg, a failed cut-plane)
|
||||||
|
|
||||||
const fileName outputDir = outputPath_/mesh_.time().timeName();
|
const fileName outputDir = outputPath_/obr_.time().timeName();
|
||||||
|
|
||||||
forAll(*this, surfI)
|
forAll(*this, surfI)
|
||||||
{
|
{
|
||||||
@ -92,9 +92,9 @@ Foam::sampledSurfaces::sampledSurfaces
|
|||||||
const bool loadFromFiles
|
const bool loadFromFiles
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
|
functionObjectState(obr, name),
|
||||||
PtrList<sampledSurface>(),
|
PtrList<sampledSurface>(),
|
||||||
name_(name),
|
obr_(obr),
|
||||||
mesh_(refCast<const fvMesh>(obr)),
|
|
||||||
loadFromFiles_(loadFromFiles),
|
loadFromFiles_(loadFromFiles),
|
||||||
outputPath_(fileName::null),
|
outputPath_(fileName::null),
|
||||||
fieldSelection_(),
|
fieldSelection_(),
|
||||||
@ -102,13 +102,19 @@ Foam::sampledSurfaces::sampledSurfaces
|
|||||||
mergeList_(),
|
mergeList_(),
|
||||||
formatter_(NULL)
|
formatter_(NULL)
|
||||||
{
|
{
|
||||||
|
// Only active if a fvMesh is available
|
||||||
|
if (setActive<fvMesh>())
|
||||||
|
{
|
||||||
|
read(dict);
|
||||||
|
}
|
||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name_;
|
outputPath_ = obr_.time().path()/".."/"postProcessing"/name_;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
outputPath_ = mesh_.time().path()/"postProcessing"/name_;
|
outputPath_ = obr_.time().path()/"postProcessing"/name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
read(dict);
|
read(dict);
|
||||||
@ -161,11 +167,11 @@ void Foam::sampledSurfaces::write()
|
|||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "Creating directory "
|
Pout<< "Creating directory "
|
||||||
<< outputPath_/mesh_.time().timeName() << nl << endl;
|
<< outputPath_/obr_.time().timeName() << nl << endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mkDir(outputPath_/mesh_.time().timeName());
|
mkDir(outputPath_/obr_.time().timeName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write geometry first if required,
|
// Write geometry first if required,
|
||||||
@ -175,7 +181,7 @@ void Foam::sampledSurfaces::write()
|
|||||||
writeGeometry();
|
writeGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
const IOobjectList objects(mesh_, mesh_.time().timeName());
|
const IOobjectList objects(obr_, obr_.time().timeName());
|
||||||
|
|
||||||
sampleAndWrite<volScalarField>(objects);
|
sampleAndWrite<volScalarField>(objects);
|
||||||
sampleAndWrite<volVectorField>(objects);
|
sampleAndWrite<volVectorField>(objects);
|
||||||
@ -211,10 +217,12 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
|
|||||||
dict.subOrEmptyDict("formatOptions").subOrEmptyDict(writeType)
|
dict.subOrEmptyDict("formatOptions").subOrEmptyDict(writeType)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||||
|
|
||||||
PtrList<sampledSurface> newList
|
PtrList<sampledSurface> newList
|
||||||
(
|
(
|
||||||
dict.lookup("surfaces"),
|
dict.lookup("surfaces"),
|
||||||
sampledSurface::iNew(mesh_)
|
sampledSurface::iNew(mesh)
|
||||||
);
|
);
|
||||||
transfer(newList);
|
transfer(newList);
|
||||||
|
|
||||||
@ -334,8 +342,10 @@ bool Foam::sampledSurfaces::update()
|
|||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||||
|
|
||||||
// Dimension as fraction of mesh bounding box
|
// Dimension as fraction of mesh bounding box
|
||||||
scalar mergeDim = mergeTol_ * mesh_.bounds().mag();
|
scalar mergeDim = mergeTol_*mesh.bounds().mag();
|
||||||
|
|
||||||
if (Pstream::master() && debug)
|
if (Pstream::master() && debug)
|
||||||
{
|
{
|
||||||
@ -374,4 +384,18 @@ bool Foam::sampledSurfaces::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::scalar Foam::sampledSurfaces::mergeTol()
|
||||||
|
{
|
||||||
|
return mergeTol_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::scalar Foam::sampledSurfaces::mergeTol(const scalar tol)
|
||||||
|
{
|
||||||
|
scalar oldTol = mergeTol_;
|
||||||
|
mergeTol_ = tol;
|
||||||
|
return oldTol;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -37,6 +37,7 @@ SourceFiles
|
|||||||
#ifndef sampledSurfaces_H
|
#ifndef sampledSurfaces_H
|
||||||
#define sampledSurfaces_H
|
#define sampledSurfaces_H
|
||||||
|
|
||||||
|
#include "functionObjectState.H"
|
||||||
#include "sampledSurface.H"
|
#include "sampledSurface.H"
|
||||||
#include "surfaceWriter.H"
|
#include "surfaceWriter.H"
|
||||||
#include "volFieldsFwd.H"
|
#include "volFieldsFwd.H"
|
||||||
@ -58,6 +59,7 @@ class dictionary;
|
|||||||
|
|
||||||
class sampledSurfaces
|
class sampledSurfaces
|
||||||
:
|
:
|
||||||
|
public functionObjectState,
|
||||||
public PtrList<sampledSurface>
|
public PtrList<sampledSurface>
|
||||||
{
|
{
|
||||||
// Private classes
|
// Private classes
|
||||||
@ -92,12 +94,8 @@ class sampledSurfaces
|
|||||||
|
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Name of this set of surfaces,
|
//- Const reference to database
|
||||||
// Also used as the name of the sampledSurfaces directory.
|
const objectRegistry& obr_;
|
||||||
const word name_;
|
|
||||||
|
|
||||||
//- Const reference to fvMesh
|
|
||||||
const fvMesh& mesh_;
|
|
||||||
|
|
||||||
//- Load fields from files (not from objectRegistry)
|
//- Load fields from files (not from objectRegistry)
|
||||||
const bool loadFromFiles_;
|
const bool loadFromFiles_;
|
||||||
@ -238,6 +236,12 @@ public:
|
|||||||
|
|
||||||
//- Update for changes of mesh due to readUpdate - expires the surfaces
|
//- Update for changes of mesh due to readUpdate - expires the surfaces
|
||||||
virtual void readUpdate(const polyMesh::readUpdateState state);
|
virtual void readUpdate(const polyMesh::readUpdateState state);
|
||||||
|
|
||||||
|
//- Get merge tolerance
|
||||||
|
static scalar mergeTol();
|
||||||
|
|
||||||
|
//- Set tolerance (and return old tolerance)
|
||||||
|
static scalar mergeTol(const scalar);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ Foam::label Foam::sampledSurfaces::classifyFields()
|
|||||||
if (loadFromFiles_)
|
if (loadFromFiles_)
|
||||||
{
|
{
|
||||||
// Check files for a particular time
|
// Check files for a particular time
|
||||||
IOobjectList objects(mesh_, mesh_.time().timeName());
|
IOobjectList objects(obr_, obr_.time().timeName());
|
||||||
wordList allFields = objects.sortedNames();
|
wordList allFields = objects.sortedNames();
|
||||||
|
|
||||||
forAll(fieldSelection_, i)
|
forAll(fieldSelection_, i)
|
||||||
@ -59,7 +59,7 @@ Foam::label Foam::sampledSurfaces::classifyFields()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Check currently available fields
|
// Check currently available fields
|
||||||
wordList allFields = mesh_.sortedNames();
|
wordList allFields = obr_.sortedNames();
|
||||||
labelList indices = findStrings(fieldSelection_, allFields);
|
labelList indices = findStrings(fieldSelection_, allFields);
|
||||||
|
|
||||||
forAll(fieldSelection_, i)
|
forAll(fieldSelection_, i)
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -72,7 +72,7 @@ void Foam::sampledSurfaces::writeSurface
|
|||||||
// skip surface without faces (eg, a failed cut-plane)
|
// skip surface without faces (eg, a failed cut-plane)
|
||||||
if (mergeList_[surfI].faces.size())
|
if (mergeList_[surfI].faces.size())
|
||||||
{
|
{
|
||||||
formatter_->write
|
fileName fName = formatter_->write
|
||||||
(
|
(
|
||||||
outputDir,
|
outputDir,
|
||||||
s.name(),
|
s.name(),
|
||||||
@ -82,6 +82,10 @@ void Foam::sampledSurfaces::writeSurface
|
|||||||
allValues,
|
allValues,
|
||||||
s.interpolate()
|
s.interpolate()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
dictionary propsDict;
|
||||||
|
propsDict.add("file", fName);
|
||||||
|
setProperty(fieldName, propsDict);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,7 +95,7 @@ void Foam::sampledSurfaces::writeSurface
|
|||||||
// skip surface without faces (eg, a failed cut-plane)
|
// skip surface without faces (eg, a failed cut-plane)
|
||||||
if (s.faces().size())
|
if (s.faces().size())
|
||||||
{
|
{
|
||||||
formatter_->write
|
fileName fName = formatter_->write
|
||||||
(
|
(
|
||||||
outputDir,
|
outputDir,
|
||||||
s.name(),
|
s.name(),
|
||||||
@ -101,6 +105,10 @@ void Foam::sampledSurfaces::writeSurface
|
|||||||
values,
|
values,
|
||||||
s.interpolate()
|
s.interpolate()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
dictionary propsDict;
|
||||||
|
propsDict.add("file", fName);
|
||||||
|
setProperty(fieldName, propsDict);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,7 +161,7 @@ void Foam::sampledSurfaces::sampleAndWrite
|
|||||||
const GeometricField<Type, fvsPatchField, surfaceMesh>& sField
|
const GeometricField<Type, fvsPatchField, surfaceMesh>& sField
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const word& fieldName = sField.name();
|
const word& fieldName = sField.name();
|
||||||
const fileName outputDir = outputPath_/sField.time().timeName();
|
const fileName outputDir = outputPath_/sField.time().timeName();
|
||||||
|
|
||||||
forAll(*this, surfI)
|
forAll(*this, surfI)
|
||||||
@ -169,6 +177,8 @@ template<class GeoField>
|
|||||||
void Foam::sampledSurfaces::sampleAndWrite(const IOobjectList& objects)
|
void Foam::sampledSurfaces::sampleAndWrite(const IOobjectList& objects)
|
||||||
{
|
{
|
||||||
wordList names;
|
wordList names;
|
||||||
|
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||||
|
|
||||||
if (loadFromFiles_)
|
if (loadFromFiles_)
|
||||||
{
|
{
|
||||||
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
|
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
|
||||||
@ -176,7 +186,7 @@ void Foam::sampledSurfaces::sampleAndWrite(const IOobjectList& objects)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
names = mesh_.thisDb().names<GeoField>();
|
names = mesh.thisDb().names<GeoField>();
|
||||||
}
|
}
|
||||||
|
|
||||||
labelList nameIDs(findStrings(fieldSelection_, names));
|
labelList nameIDs(findStrings(fieldSelection_, names));
|
||||||
@ -199,11 +209,11 @@ void Foam::sampledSurfaces::sampleAndWrite(const IOobjectList& objects)
|
|||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
fieldName,
|
fieldName,
|
||||||
mesh_.time().timeName(),
|
mesh.time().timeName(),
|
||||||
mesh_,
|
mesh,
|
||||||
IOobject::MUST_READ
|
IOobject::MUST_READ
|
||||||
),
|
),
|
||||||
mesh_
|
mesh
|
||||||
);
|
);
|
||||||
|
|
||||||
sampleAndWrite(fld);
|
sampleAndWrite(fld);
|
||||||
@ -212,7 +222,7 @@ void Foam::sampledSurfaces::sampleAndWrite(const IOobjectList& objects)
|
|||||||
{
|
{
|
||||||
sampleAndWrite
|
sampleAndWrite
|
||||||
(
|
(
|
||||||
mesh_.thisDb().lookupObject<GeoField>(fieldName)
|
mesh.thisDb().lookupObject<GeoField>(fieldName)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,117 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2015 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 "boundaryDataSurfaceWriter.H"
|
||||||
|
#include "makeSurfaceWriterMethods.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
makeSurfaceWriterType(boundaryDataSurfaceWriter);
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::boundaryDataSurfaceWriter::boundaryDataSurfaceWriter()
|
||||||
|
:
|
||||||
|
surfaceWriter()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::boundaryDataSurfaceWriter::~boundaryDataSurfaceWriter()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::fileName Foam::boundaryDataSurfaceWriter::write
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const bool verbose
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const fileName baseDir(outputDir.path()/surfaceName);
|
||||||
|
const fileName timeName(outputDir.name());
|
||||||
|
|
||||||
|
|
||||||
|
// Construct dummy time to use as an objectRegistry
|
||||||
|
const fileName caseDir(getEnv("FOAM_CASE"));
|
||||||
|
Time dummyTime
|
||||||
|
(
|
||||||
|
caseDir.path(), //rootPath,
|
||||||
|
caseDir.name(), //caseName,
|
||||||
|
"system", //systemName,
|
||||||
|
"constant", //constantName,
|
||||||
|
false //enableFunctionObjects
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Write points
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "Writing points to " << baseDir/"points" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointIOField pts
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
baseDir/"points",
|
||||||
|
dummyTime,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
),
|
||||||
|
points
|
||||||
|
);
|
||||||
|
|
||||||
|
{
|
||||||
|
// Do like regIOobject::writeObject but don't do instance() adaptation
|
||||||
|
// since this would write to e.g. 0/ instead of postProcessing/
|
||||||
|
|
||||||
|
// Try opening an OFstream for object
|
||||||
|
mkDir(pts.path());
|
||||||
|
OFstream os(pts.objectPath());
|
||||||
|
|
||||||
|
pts.writeHeader(os);
|
||||||
|
pts.writeData(os);
|
||||||
|
pts.writeEndDivider(os);
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// create write methods
|
||||||
|
defineSurfaceWriterWriteFields(Foam::boundaryDataSurfaceWriter);
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,222 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2015 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::boundaryDataSurfaceWriter
|
||||||
|
|
||||||
|
Description
|
||||||
|
A surfaceWriter for outputting to a form useable for the
|
||||||
|
timeVaryingMapped boundary condition. This reads the data from
|
||||||
|
constant/boundaryData/<patch>
|
||||||
|
|
||||||
|
Typical way of working:
|
||||||
|
- use a sampledSurface of type 'patch' (to sample a patch):
|
||||||
|
surfaces
|
||||||
|
{
|
||||||
|
type surfaces;
|
||||||
|
surfaceFormat boundaryData;
|
||||||
|
fields ( p );
|
||||||
|
surfaces
|
||||||
|
(
|
||||||
|
outlet
|
||||||
|
{
|
||||||
|
type patch;
|
||||||
|
patches (outlet);
|
||||||
|
interpolate false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
- write using this writer.
|
||||||
|
- move postProcessing/surfaces/outlet to constant/boundaryData/outlet
|
||||||
|
in your destination case.
|
||||||
|
- use a timeVaryingMappedFixedValue bc to read&interpolate
|
||||||
|
the profile:
|
||||||
|
type timeVaryingMappedFixedValue;
|
||||||
|
setAverage false; // do not use read average
|
||||||
|
offset 0; // do not apply offset to values
|
||||||
|
|
||||||
|
Note:
|
||||||
|
- with 'interpolate false' the data is on the face centres of the
|
||||||
|
patch. Take care that a 2D geometry will only have a single row
|
||||||
|
of face centres so might not provide a valid triangulation
|
||||||
|
(this is what timeVaryingMappedFixedValue uses to do interpolation)
|
||||||
|
(Alternatively use timeVaryingMappedFixedValue with mapMethod 'nearest')
|
||||||
|
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
boundaryDataSurfaceWriter.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef boundaryDataSurfaceWriter_H
|
||||||
|
#define boundaryDataSurfaceWriter_H
|
||||||
|
|
||||||
|
#include "surfaceWriter.H"
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class boundaryDataSurfaceWriter Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class boundaryDataSurfaceWriter
|
||||||
|
:
|
||||||
|
public surfaceWriter
|
||||||
|
{
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Templated write operation
|
||||||
|
template<class Type>
|
||||||
|
fileName writeTemplate
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName,
|
||||||
|
const Field<Type>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("boundaryData");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
boundaryDataSurfaceWriter();
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~boundaryDataSurfaceWriter();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Write single surface geometry to file.
|
||||||
|
virtual fileName write
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const bool verbose = false
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
//- Write scalarField for a single surface to file.
|
||||||
|
// One value per face or vertex (isNodeValues = true)
|
||||||
|
virtual fileName write
|
||||||
|
(
|
||||||
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
|
const fileName& surfaceName, // name of surface
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName, // name of field
|
||||||
|
const Field<scalar>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose = false
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Write vectorField for a single surface to file.
|
||||||
|
// One value per face or vertex (isNodeValues = true)
|
||||||
|
virtual fileName write
|
||||||
|
(
|
||||||
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
|
const fileName& surfaceName, // name of surface
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName, // name of field
|
||||||
|
const Field<vector>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose = false
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Write sphericalTensorField for a single surface to file.
|
||||||
|
// One value per face or vertex (isNodeValues = true)
|
||||||
|
virtual fileName write
|
||||||
|
(
|
||||||
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
|
const fileName& surfaceName, // name of surface
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName, // name of field
|
||||||
|
const Field<sphericalTensor>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose = false
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Write symmTensorField for a single surface to file.
|
||||||
|
// One value per face or vertex (isNodeValues = true)
|
||||||
|
virtual fileName write
|
||||||
|
(
|
||||||
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
|
const fileName& surfaceName, // name of surface
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName, // name of field
|
||||||
|
const Field<symmTensor>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose = false
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Write tensorField for a single surface to file.
|
||||||
|
// One value per face or vertex (isNodeValues = true)
|
||||||
|
virtual fileName write
|
||||||
|
(
|
||||||
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
|
const fileName& surfaceName, // name of surface
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName, // name of field
|
||||||
|
const Field<tensor>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose = false
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "boundaryDataSurfaceWriterTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,146 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify i
|
||||||
|
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 "OFstream.H"
|
||||||
|
#include "OSspecific.H"
|
||||||
|
#include "IOmanip.H"
|
||||||
|
#include "Time.H"
|
||||||
|
#include "pointIOField.H"
|
||||||
|
#include "AverageIOField.H"
|
||||||
|
#include "primitivePatch.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::fileName Foam::boundaryDataSurfaceWriter::writeTemplate
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName,
|
||||||
|
const Field<Type>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const fileName baseDir(outputDir.path()/surfaceName);
|
||||||
|
const fileName timeName(outputDir.name());
|
||||||
|
|
||||||
|
|
||||||
|
// Construct dummy time to use as an objectRegistry
|
||||||
|
const fileName caseDir(getEnv("FOAM_CASE"));
|
||||||
|
Time dummyTime
|
||||||
|
(
|
||||||
|
caseDir.path(), //rootPath,
|
||||||
|
caseDir.name(), //caseName,
|
||||||
|
"system", //systemName,
|
||||||
|
"constant", //constantName,
|
||||||
|
false //enableFunctionObjects
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Write points
|
||||||
|
|
||||||
|
pointIOField pts
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
baseDir/"points",
|
||||||
|
dummyTime,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isNodeValues)
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "Writing points to " << baseDir/"points" << endl;
|
||||||
|
}
|
||||||
|
pts = points;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "Writing face centres to " << baseDir/"points" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
primitivePatch pp(SubList<face>(faces, faces.size()), points);
|
||||||
|
|
||||||
|
pts = pp.faceCentres();
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Do like regIOobject::writeObject but don't do instance() adaptation
|
||||||
|
// since this would write to e.g. 0/ instead of postProcessing/
|
||||||
|
|
||||||
|
// Try opening an OFstream for object
|
||||||
|
mkDir(pts.path());
|
||||||
|
OFstream os(pts.objectPath());
|
||||||
|
|
||||||
|
pts.writeHeader(os);
|
||||||
|
pts.writeData(os);
|
||||||
|
pts.writeEndDivider(os);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Write field
|
||||||
|
{
|
||||||
|
AverageIOField<Type> vals
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
baseDir/timeName/fieldName,
|
||||||
|
dummyTime,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
),
|
||||||
|
pTraits<Type>::zero,
|
||||||
|
values
|
||||||
|
);
|
||||||
|
|
||||||
|
// Do like regIOobject::writeObject but don't do instance() adaptation
|
||||||
|
// since this would write to e.g. 0/ instead of postProcessing/
|
||||||
|
|
||||||
|
// Try opening an OFstream for object
|
||||||
|
mkDir(vals.path());
|
||||||
|
OFstream os(vals.objectPath());
|
||||||
|
|
||||||
|
vals.writeHeader(os);
|
||||||
|
vals.writeData(os);
|
||||||
|
vals.writeEndDivider(os);
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -24,10 +24,6 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "dxSurfaceWriter.H"
|
#include "dxSurfaceWriter.H"
|
||||||
|
|
||||||
#include "OFstream.H"
|
|
||||||
#include "OSspecific.H"
|
|
||||||
|
|
||||||
#include "makeSurfaceWriterMethods.H"
|
#include "makeSurfaceWriterMethods.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
@ -215,58 +211,6 @@ namespace Foam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// arbitrary field
|
|
||||||
template<class Type>
|
|
||||||
inline void Foam::dxSurfaceWriter::writeData
|
|
||||||
(
|
|
||||||
Ostream& os,
|
|
||||||
const Field<Type>& values
|
|
||||||
)
|
|
||||||
{
|
|
||||||
os << "object 3 class array type float rank 0 items "
|
|
||||||
<< values.size() << " data follows" << nl;
|
|
||||||
|
|
||||||
forAll(values, elemI)
|
|
||||||
{
|
|
||||||
os << float(0.0) << nl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::dxSurfaceWriter::writeTemplate
|
|
||||||
(
|
|
||||||
const fileName& outputDir,
|
|
||||||
const fileName& surfaceName,
|
|
||||||
const pointField& points,
|
|
||||||
const faceList& faces,
|
|
||||||
const word& fieldName,
|
|
||||||
const Field<Type>& values,
|
|
||||||
const bool isNodeValues,
|
|
||||||
const bool verbose
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
if (!isDir(outputDir))
|
|
||||||
{
|
|
||||||
mkDir(outputDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
OFstream os
|
|
||||||
(
|
|
||||||
outputDir/fieldName + '_' + surfaceName + ".dx"
|
|
||||||
);
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
writeGeometry(os, points, faces);
|
|
||||||
writeData(os, values);
|
|
||||||
writeTrailer(os, isNodeValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::dxSurfaceWriter::dxSurfaceWriter()
|
Foam::dxSurfaceWriter::dxSurfaceWriter()
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -61,7 +61,7 @@ class dxSurfaceWriter
|
|||||||
|
|
||||||
//- Templated write operation
|
//- Templated write operation
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void writeTemplate
|
fileName writeTemplate
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -94,7 +94,7 @@ public:
|
|||||||
|
|
||||||
//- Write scalarField for a single surface to file.
|
//- Write scalarField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -108,7 +108,7 @@ public:
|
|||||||
|
|
||||||
//- Write vectorField for a single surface to file.
|
//- Write vectorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -122,7 +122,7 @@ public:
|
|||||||
|
|
||||||
//- Write sphericalTensorField for a single surface to file.
|
//- Write sphericalTensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -136,7 +136,7 @@ public:
|
|||||||
|
|
||||||
//- Write symmTensorField for a single surface to file.
|
//- Write symmTensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -150,7 +150,7 @@ public:
|
|||||||
|
|
||||||
//- Write tensorField for a single surface to file.
|
//- Write tensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -161,7 +161,6 @@ public:
|
|||||||
const bool isNodeValues,
|
const bool isNodeValues,
|
||||||
const bool verbose = false
|
const bool verbose = false
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -171,6 +170,12 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "dxSurfaceWriterTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -0,0 +1,81 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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 "OFstream.H"
|
||||||
|
#include "OSspecific.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
inline void Foam::dxSurfaceWriter::writeData
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const Field<Type>& values
|
||||||
|
)
|
||||||
|
{
|
||||||
|
os << "object 3 class array type float rank 0 items "
|
||||||
|
<< values.size() << " data follows" << nl;
|
||||||
|
|
||||||
|
forAll(values, elemI)
|
||||||
|
{
|
||||||
|
os << float(0.0) << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::fileName Foam::dxSurfaceWriter::writeTemplate
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName,
|
||||||
|
const Field<Type>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (!isDir(outputDir))
|
||||||
|
{
|
||||||
|
mkDir(outputDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
OFstream os(outputDir/fieldName + '_' + surfaceName + ".dx");
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
writeGeometry(os, points, faces);
|
||||||
|
writeData(os, values);
|
||||||
|
writeTrailer(os, isNodeValues);
|
||||||
|
|
||||||
|
return os.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -24,13 +24,7 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "ensightSurfaceWriter.H"
|
#include "ensightSurfaceWriter.H"
|
||||||
|
|
||||||
#include "OFstream.H"
|
|
||||||
#include "OSspecific.H"
|
|
||||||
#include "IOmanip.H"
|
|
||||||
#include "ensightPartFaces.H"
|
#include "ensightPartFaces.H"
|
||||||
#include "ensightPTraits.H"
|
|
||||||
|
|
||||||
#include "makeSurfaceWriterMethods.H"
|
#include "makeSurfaceWriterMethods.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
@ -42,83 +36,13 @@ namespace Foam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::ensightSurfaceWriter::writeTemplate
|
|
||||||
(
|
|
||||||
const fileName& outputDir,
|
|
||||||
const fileName& surfaceName,
|
|
||||||
const pointField& points,
|
|
||||||
const faceList& faces,
|
|
||||||
const word& fieldName,
|
|
||||||
const Field<Type>& values,
|
|
||||||
const bool isNodeValues,
|
|
||||||
const bool verbose
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
if (!isDir(outputDir/fieldName))
|
|
||||||
{
|
|
||||||
mkDir(outputDir/fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// const scalar timeValue = Foam::name(this->mesh().time().timeValue());
|
|
||||||
const scalar timeValue = 0.0;
|
|
||||||
|
|
||||||
OFstream osCase(outputDir/fieldName/surfaceName + ".case");
|
|
||||||
ensightGeoFile osGeom
|
|
||||||
(
|
|
||||||
outputDir/fieldName/surfaceName + ".000.mesh",
|
|
||||||
writeFormat_
|
|
||||||
);
|
|
||||||
ensightFile osField
|
|
||||||
(
|
|
||||||
outputDir/fieldName/surfaceName + ".000." + fieldName,
|
|
||||||
writeFormat_
|
|
||||||
);
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
Info<< "Writing case file to " << osCase.name() << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
osCase
|
|
||||||
<< "FORMAT" << nl
|
|
||||||
<< "type: ensight gold" << nl
|
|
||||||
<< nl
|
|
||||||
<< "GEOMETRY" << nl
|
|
||||||
<< "model: 1 " << osGeom.name().name() << nl
|
|
||||||
<< nl
|
|
||||||
<< "VARIABLE" << nl
|
|
||||||
<< ensightPTraits<Type>::typeName << " per "
|
|
||||||
<< word(isNodeValues ? "node:" : "element:") << setw(10) << 1
|
|
||||||
<< " " << fieldName
|
|
||||||
<< " " << surfaceName.c_str() << ".***." << fieldName << nl
|
|
||||||
<< nl
|
|
||||||
<< "TIME" << nl
|
|
||||||
<< "time set: 1" << nl
|
|
||||||
<< "number of steps: 1" << nl
|
|
||||||
<< "filename start number: 0" << nl
|
|
||||||
<< "filename increment: 1" << nl
|
|
||||||
<< "time values:" << nl
|
|
||||||
<< timeValue << nl
|
|
||||||
<< nl;
|
|
||||||
|
|
||||||
ensightPartFaces ensPart(0, osGeom.name().name(), points, faces, true);
|
|
||||||
osGeom << ensPart;
|
|
||||||
|
|
||||||
// Write field
|
|
||||||
osField.writeKeyword(ensightPTraits<Type>::typeName);
|
|
||||||
ensPart.writeField(osField, values, isNodeValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::ensightSurfaceWriter::ensightSurfaceWriter()
|
Foam::ensightSurfaceWriter::ensightSurfaceWriter()
|
||||||
:
|
:
|
||||||
surfaceWriter(),
|
surfaceWriter(),
|
||||||
writeFormat_(IOstream::ASCII)
|
writeFormat_(IOstream::ASCII),
|
||||||
|
collateTimes_(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -132,6 +56,7 @@ Foam::ensightSurfaceWriter::ensightSurfaceWriter(const dictionary& options)
|
|||||||
{
|
{
|
||||||
writeFormat_ = IOstream::formatEnum(options.lookup("format"));
|
writeFormat_ = IOstream::formatEnum(options.lookup("format"));
|
||||||
}
|
}
|
||||||
|
options.readIfPresent("collateTimes", collateTimes_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -143,7 +68,7 @@ Foam::ensightSurfaceWriter::~ensightSurfaceWriter()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::ensightSurfaceWriter::write
|
Foam::fileName Foam::ensightSurfaceWriter::write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -163,7 +88,7 @@ void Foam::ensightSurfaceWriter::write
|
|||||||
OFstream osCase(outputDir/surfaceName + ".case");
|
OFstream osCase(outputDir/surfaceName + ".case");
|
||||||
ensightGeoFile osGeom
|
ensightGeoFile osGeom
|
||||||
(
|
(
|
||||||
outputDir/surfaceName + ".000.mesh",
|
outputDir/surfaceName + ".0000.mesh",
|
||||||
writeFormat_
|
writeFormat_
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -190,6 +115,8 @@ void Foam::ensightSurfaceWriter::write
|
|||||||
|
|
||||||
ensightPartFaces ensPart(0, osGeom.name().name(), points, faces, true);
|
ensightPartFaces ensPart(0, osGeom.name().name(), points, faces, true);
|
||||||
osGeom << ensPart;
|
osGeom << ensPart;
|
||||||
|
|
||||||
|
return osCase.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -55,12 +55,42 @@ class ensightSurfaceWriter
|
|||||||
//- Write option (default is IOstream::ASCII
|
//- Write option (default is IOstream::ASCII
|
||||||
IOstream::streamFormat writeFormat_;
|
IOstream::streamFormat writeFormat_;
|
||||||
|
|
||||||
|
bool collateTimes_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Templated write operation - one file per timestep
|
||||||
|
template<class Type>
|
||||||
|
fileName writeCollated
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName,
|
||||||
|
const Field<Type>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Templated write operation - all time steps in single file
|
||||||
|
template<class Type>
|
||||||
|
fileName writeUncollated
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName,
|
||||||
|
const Field<Type>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Templated write operation
|
//- Templated write operation
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void writeTemplate
|
fileName writeTemplate
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -96,14 +126,14 @@ public:
|
|||||||
|
|
||||||
//- True if the surface format supports geometry in a separate file.
|
//- True if the surface format supports geometry in a separate file.
|
||||||
// False if geometry and field must be in a single file
|
// False if geometry and field must be in a single file
|
||||||
virtual bool separateGeometry()
|
virtual bool separateGeometry() const
|
||||||
{
|
{
|
||||||
return true;
|
return !collateTimes_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Write single surface geometry to file.
|
//- Write single surface geometry to file.
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -115,7 +145,7 @@ public:
|
|||||||
|
|
||||||
//- Write scalarField for a single surface to file.
|
//- Write scalarField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -129,7 +159,7 @@ public:
|
|||||||
|
|
||||||
//- Write vectorField for a single surface to file.
|
//- Write vectorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -143,7 +173,7 @@ public:
|
|||||||
|
|
||||||
//- Write sphericalTensorField for a single surface to file.
|
//- Write sphericalTensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -157,7 +187,7 @@ public:
|
|||||||
|
|
||||||
//- Write symmTensorField for a single surface to file.
|
//- Write symmTensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -171,7 +201,7 @@ public:
|
|||||||
|
|
||||||
//- Write tensorField for a single surface to file.
|
//- Write tensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -182,7 +212,6 @@ public:
|
|||||||
const bool isNodeValues,
|
const bool isNodeValues,
|
||||||
const bool verbose = false
|
const bool verbose = false
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -192,6 +221,12 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "ensightSurfaceWriterTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -0,0 +1,339 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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 "IOmanip.H"
|
||||||
|
#include "IFstream.H"
|
||||||
|
#include "OFstream.H"
|
||||||
|
#include "OSspecific.H"
|
||||||
|
#include "ensightPartFaces.H"
|
||||||
|
#include "ensightPTraits.H"
|
||||||
|
#include "OStringStream.H"
|
||||||
|
#include "regExp.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::fileName Foam::ensightSurfaceWriter::writeUncollated
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName,
|
||||||
|
const Field<Type>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (!isDir(outputDir/fieldName))
|
||||||
|
{
|
||||||
|
mkDir(outputDir/fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// const scalar timeValue = Foam::name(this->mesh().time().timeValue());
|
||||||
|
const scalar timeValue = 0.0;
|
||||||
|
|
||||||
|
OFstream osCase(outputDir/fieldName/surfaceName + ".case");
|
||||||
|
ensightGeoFile osGeom
|
||||||
|
(
|
||||||
|
outputDir/fieldName/surfaceName + ".0000.mesh",
|
||||||
|
writeFormat_
|
||||||
|
);
|
||||||
|
ensightFile osField
|
||||||
|
(
|
||||||
|
outputDir/fieldName/surfaceName + ".0000." + fieldName,
|
||||||
|
writeFormat_
|
||||||
|
);
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "Writing case file to " << osCase.name() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
osCase
|
||||||
|
<< "FORMAT" << nl
|
||||||
|
<< "type: ensight gold" << nl
|
||||||
|
<< nl
|
||||||
|
<< "GEOMETRY" << nl
|
||||||
|
<< "model: 1 " << osGeom.name().name() << nl
|
||||||
|
<< nl
|
||||||
|
<< "VARIABLE" << nl
|
||||||
|
<< ensightPTraits<Type>::typeName << " per "
|
||||||
|
<< word(isNodeValues ? "node:" : "element:") << setw(10) << 1
|
||||||
|
<< " " << fieldName
|
||||||
|
<< " " << surfaceName.c_str() << ".****." << fieldName << nl
|
||||||
|
<< nl
|
||||||
|
<< "TIME" << nl
|
||||||
|
<< "time set: 1" << nl
|
||||||
|
<< "number of steps: 1" << nl
|
||||||
|
<< "filename start number: 0" << nl
|
||||||
|
<< "filename increment: 1" << nl
|
||||||
|
<< "time values:" << nl
|
||||||
|
<< timeValue << nl
|
||||||
|
<< nl;
|
||||||
|
|
||||||
|
ensightPartFaces ensPart(0, osGeom.name().name(), points, faces, true);
|
||||||
|
osGeom << ensPart;
|
||||||
|
|
||||||
|
// Write field
|
||||||
|
osField.writeKeyword(ensightPTraits<Type>::typeName);
|
||||||
|
ensPart.writeField(osField, values, isNodeValues);
|
||||||
|
|
||||||
|
return osCase.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::fileName Foam::ensightSurfaceWriter::writeCollated
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName,
|
||||||
|
const Field<Type>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
|
||||||
|
const fileName baseDir = outputDir.path()/surfaceName;
|
||||||
|
const fileName timeDir = outputDir.name();
|
||||||
|
|
||||||
|
if (!isDir(baseDir))
|
||||||
|
{
|
||||||
|
mkDir(baseDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
const fileName meshFile(baseDir/surfaceName + ".0000.mesh");
|
||||||
|
const scalar timeValue = readScalar(IStringStream(timeDir)());
|
||||||
|
label timeIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// Do case file
|
||||||
|
{
|
||||||
|
dictionary dict;
|
||||||
|
scalarList times;
|
||||||
|
bool stateChanged = false;
|
||||||
|
|
||||||
|
if (isFile(baseDir/"fieldsDict"))
|
||||||
|
{
|
||||||
|
IFstream is(baseDir/"fieldsDict");
|
||||||
|
if (is.good() && dict.read(is))
|
||||||
|
{
|
||||||
|
dict.lookup("times") >> times;
|
||||||
|
const scalar timeValue = readScalar(IStringStream(timeDir)());
|
||||||
|
label index = findLower(times, timeValue);
|
||||||
|
timeIndex = index+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Update stored times list
|
||||||
|
times.setSize(timeIndex+1, -1);
|
||||||
|
|
||||||
|
if (times[timeIndex] != timeValue)
|
||||||
|
{
|
||||||
|
stateChanged = true;
|
||||||
|
}
|
||||||
|
times[timeIndex] = timeValue;
|
||||||
|
|
||||||
|
|
||||||
|
// Add my information to dictionary
|
||||||
|
{
|
||||||
|
dict.set("times", times);
|
||||||
|
if (dict.found("fields"))
|
||||||
|
{
|
||||||
|
dictionary& fieldsDict = dict.subDict("fields");
|
||||||
|
if (!fieldsDict.found(fieldName))
|
||||||
|
{
|
||||||
|
dictionary fieldDict;
|
||||||
|
fieldDict.set("type", ensightPTraits<Type>::typeName);
|
||||||
|
fieldsDict.set(fieldName, fieldDict);
|
||||||
|
|
||||||
|
stateChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dictionary fieldDict;
|
||||||
|
fieldDict.set("type", ensightPTraits<Type>::typeName);
|
||||||
|
|
||||||
|
dictionary fieldsDict;
|
||||||
|
fieldsDict.set(fieldName, fieldDict);
|
||||||
|
|
||||||
|
dict.set("fields", fieldsDict);
|
||||||
|
|
||||||
|
stateChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (stateChanged)
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "Writing state file to fieldsDict" << endl;
|
||||||
|
}
|
||||||
|
OFstream os(baseDir/"fieldsDict");
|
||||||
|
os << dict;
|
||||||
|
|
||||||
|
|
||||||
|
OFstream osCase(baseDir/surfaceName + ".case");
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "Writing case file to " << osCase.name() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
osCase
|
||||||
|
<< "FORMAT" << nl
|
||||||
|
<< "type: ensight gold" << nl
|
||||||
|
<< nl
|
||||||
|
<< "GEOMETRY" << nl
|
||||||
|
<< "model: 1 " << meshFile.name() << nl
|
||||||
|
<< nl
|
||||||
|
<< "VARIABLE" << nl;
|
||||||
|
const dictionary& fieldsDict = dict.subDict("fields");
|
||||||
|
forAllConstIter(dictionary, fieldsDict, iter)
|
||||||
|
{
|
||||||
|
const word& fieldName = iter().keyword();
|
||||||
|
const word fieldType(iter().dict().lookup("type"));
|
||||||
|
|
||||||
|
osCase
|
||||||
|
<< fieldType << " per "
|
||||||
|
<< word(isNodeValues ? "node:" : "element:")
|
||||||
|
<< setw(10) << 1
|
||||||
|
<< setw(15) << fieldName
|
||||||
|
<< " " << surfaceName.c_str() << ".****." << fieldName
|
||||||
|
<< nl;
|
||||||
|
}
|
||||||
|
osCase << nl;
|
||||||
|
|
||||||
|
osCase
|
||||||
|
<< "TIME" << nl
|
||||||
|
<< "time set: 1" << nl
|
||||||
|
<< "number of steps: " << timeIndex+1 << nl
|
||||||
|
<< "filename start number: 0" << nl
|
||||||
|
<< "filename increment: 1" << nl
|
||||||
|
<< "time values:" << nl;
|
||||||
|
forAll(times, timeI)
|
||||||
|
{
|
||||||
|
osCase << setw(12) << times[timeI] << " ";
|
||||||
|
|
||||||
|
if (timeI != 0 && (timeI % 6) == 0)
|
||||||
|
{
|
||||||
|
osCase << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
osCase << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Write geometry
|
||||||
|
ensightPartFaces ensPart(0, meshFile.name(), points, faces, true);
|
||||||
|
if (!exists(meshFile))
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "Writing mesh file to " << meshFile.name() << endl;
|
||||||
|
}
|
||||||
|
ensightGeoFile osGeom(meshFile, writeFormat_);
|
||||||
|
osGeom << ensPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Get string representation
|
||||||
|
string timeString;
|
||||||
|
{
|
||||||
|
OStringStream os;
|
||||||
|
os.stdStream().fill('0');
|
||||||
|
os << setw(4) << timeIndex;
|
||||||
|
timeString = os.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write field
|
||||||
|
ensightFile osField
|
||||||
|
(
|
||||||
|
baseDir/surfaceName + "." + timeString + "." + fieldName,
|
||||||
|
writeFormat_
|
||||||
|
);
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "Writing field file to " << osField.name() << endl;
|
||||||
|
}
|
||||||
|
osField.writeKeyword(ensightPTraits<Type>::typeName);
|
||||||
|
ensPart.writeField(osField, values, isNodeValues);
|
||||||
|
|
||||||
|
return baseDir/surfaceName + ".case";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::fileName Foam::ensightSurfaceWriter::writeTemplate
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName,
|
||||||
|
const Field<Type>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (collateTimes_)
|
||||||
|
{
|
||||||
|
return writeCollated
|
||||||
|
(
|
||||||
|
outputDir,
|
||||||
|
surfaceName,
|
||||||
|
points,
|
||||||
|
faces,
|
||||||
|
fieldName,
|
||||||
|
values,
|
||||||
|
isNodeValues,
|
||||||
|
verbose
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return writeUncollated
|
||||||
|
(
|
||||||
|
outputDir,
|
||||||
|
surfaceName,
|
||||||
|
points,
|
||||||
|
faces,
|
||||||
|
fieldName,
|
||||||
|
values,
|
||||||
|
isNodeValues,
|
||||||
|
verbose
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -24,10 +24,6 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "foamFileSurfaceWriter.H"
|
#include "foamFileSurfaceWriter.H"
|
||||||
|
|
||||||
#include "OFstream.H"
|
|
||||||
#include "OSspecific.H"
|
|
||||||
|
|
||||||
#include "makeSurfaceWriterMethods.H"
|
#include "makeSurfaceWriterMethods.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
@ -38,49 +34,6 @@ namespace Foam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::foamFileSurfaceWriter::writeTemplate
|
|
||||||
(
|
|
||||||
const fileName& outputDir,
|
|
||||||
const fileName& surfaceName,
|
|
||||||
const pointField& points,
|
|
||||||
const faceList& faces,
|
|
||||||
const word& fieldName,
|
|
||||||
const Field<Type>& values,
|
|
||||||
const bool isNodeValues,
|
|
||||||
const bool verbose
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
fileName surfaceDir(outputDir/surfaceName);
|
|
||||||
|
|
||||||
if (!isDir(surfaceDir))
|
|
||||||
{
|
|
||||||
mkDir(surfaceDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
Info<< "Writing field " << fieldName << " to " << surfaceDir << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// geometry should already have been written
|
|
||||||
// Values to separate directory (e.g. "scalarField/p")
|
|
||||||
|
|
||||||
fileName foamName(pTraits<Type>::typeName);
|
|
||||||
fileName valuesDir(surfaceDir / (foamName + Field<Type>::typeName));
|
|
||||||
|
|
||||||
if (!isDir(valuesDir))
|
|
||||||
{
|
|
||||||
mkDir(valuesDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
// values
|
|
||||||
OFstream(valuesDir/fieldName)() << values;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::foamFileSurfaceWriter::foamFileSurfaceWriter()
|
Foam::foamFileSurfaceWriter::foamFileSurfaceWriter()
|
||||||
@ -97,7 +50,7 @@ Foam::foamFileSurfaceWriter::~foamFileSurfaceWriter()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::foamFileSurfaceWriter::write
|
Foam::fileName Foam::foamFileSurfaceWriter::write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -135,6 +88,8 @@ void Foam::foamFileSurfaceWriter::write
|
|||||||
}
|
}
|
||||||
|
|
||||||
OFstream(surfaceDir/"faceCentres")() << faceCentres;
|
OFstream(surfaceDir/"faceCentres")() << faceCentres;
|
||||||
|
|
||||||
|
return surfaceDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -54,7 +54,7 @@ class foamFileSurfaceWriter
|
|||||||
|
|
||||||
//- Templated write operation
|
//- Templated write operation
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void writeTemplate
|
fileName writeTemplate
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -87,13 +87,13 @@ public:
|
|||||||
|
|
||||||
//- True if the surface format supports geometry in a separate file.
|
//- True if the surface format supports geometry in a separate file.
|
||||||
// False if geometry and field must be in a single file
|
// False if geometry and field must be in a single file
|
||||||
virtual bool separateGeometry()
|
virtual bool separateGeometry() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Write single surface geometry to file.
|
//- Write single surface geometry to file.
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -105,7 +105,7 @@ public:
|
|||||||
|
|
||||||
//- Write scalarField for a single surface to file.
|
//- Write scalarField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -119,7 +119,7 @@ public:
|
|||||||
|
|
||||||
//- Write vectorField for a single surface to file.
|
//- Write vectorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -133,7 +133,7 @@ public:
|
|||||||
|
|
||||||
//- Write sphericalTensorField for a single surface to file.
|
//- Write sphericalTensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -147,7 +147,7 @@ public:
|
|||||||
|
|
||||||
//- Write symmTensorField for a single surface to file.
|
//- Write symmTensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -161,7 +161,7 @@ public:
|
|||||||
|
|
||||||
//- Write tensorField for a single surface to file.
|
//- Write tensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -172,7 +172,6 @@ public:
|
|||||||
const bool isNodeValues,
|
const bool isNodeValues,
|
||||||
const bool verbose = false
|
const bool verbose = false
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -182,6 +181,12 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "foamFileSurfaceWriterTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -0,0 +1,74 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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 "OFstream.H"
|
||||||
|
#include "OSspecific.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::fileName Foam::foamFileSurfaceWriter::writeTemplate
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName,
|
||||||
|
const Field<Type>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
fileName surfaceDir(outputDir/surfaceName);
|
||||||
|
|
||||||
|
if (!isDir(surfaceDir))
|
||||||
|
{
|
||||||
|
mkDir(surfaceDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "Writing field " << fieldName << " to " << surfaceDir << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// geometry should already have been written
|
||||||
|
// Values to separate directory (e.g. "scalarField/p")
|
||||||
|
|
||||||
|
fileName foamName(pTraits<Type>::typeName);
|
||||||
|
fileName valuesDir(surfaceDir/(foamName + Field<Type>::typeName));
|
||||||
|
|
||||||
|
if (!isDir(valuesDir))
|
||||||
|
{
|
||||||
|
mkDir(valuesDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
// values
|
||||||
|
OFstream(valuesDir/fieldName)() << values;
|
||||||
|
|
||||||
|
return valuesDir/fieldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -47,7 +47,7 @@ namespace Foam
|
|||||||
|
|
||||||
|
|
||||||
#define defineSurfaceWriterWriteField(ThisClass, FieldType) \
|
#define defineSurfaceWriterWriteField(ThisClass, FieldType) \
|
||||||
void ThisClass::write \
|
Foam::fileName ThisClass::write \
|
||||||
( \
|
( \
|
||||||
const fileName& outputDir, \
|
const fileName& outputDir, \
|
||||||
const fileName& surfaceName, \
|
const fileName& surfaceName, \
|
||||||
@ -59,7 +59,7 @@ namespace Foam
|
|||||||
const bool verbose \
|
const bool verbose \
|
||||||
) const \
|
) const \
|
||||||
{ \
|
{ \
|
||||||
writeTemplate \
|
return writeTemplate \
|
||||||
( \
|
( \
|
||||||
outputDir, \
|
outputDir, \
|
||||||
surfaceName, \
|
surfaceName, \
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -35,7 +35,7 @@ namespace Foam
|
|||||||
makeSurfaceWriterType(nastranSurfaceWriter);
|
makeSurfaceWriterType(nastranSurfaceWriter);
|
||||||
addToRunTimeSelectionTable(surfaceWriter, nastranSurfaceWriter, wordDict);
|
addToRunTimeSelectionTable(surfaceWriter, nastranSurfaceWriter, wordDict);
|
||||||
|
|
||||||
// create write methods
|
// Create write methods
|
||||||
defineSurfaceWriterWriteFields(nastranSurfaceWriter);
|
defineSurfaceWriterWriteFields(nastranSurfaceWriter);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
@ -46,8 +46,19 @@ namespace Foam
|
|||||||
"free"
|
"free"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const NamedEnum<nastranSurfaceWriter::writeFormat, 3>
|
const NamedEnum<nastranSurfaceWriter::writeFormat, 3>
|
||||||
nastranSurfaceWriter::writeFormatNames_;
|
nastranSurfaceWriter::writeFormatNames_;
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char* NamedEnum<nastranSurfaceWriter::dataFormat, 2>::names[] =
|
||||||
|
{
|
||||||
|
"PLOAD2",
|
||||||
|
"PLOAD4"
|
||||||
|
};
|
||||||
|
|
||||||
|
const NamedEnum<nastranSurfaceWriter::dataFormat, 2>
|
||||||
|
nastranSurfaceWriter::dataFormatNames_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -57,7 +68,7 @@ void Foam::nastranSurfaceWriter::formatOS(OFstream& os) const
|
|||||||
{
|
{
|
||||||
os.setf(ios_base::scientific);
|
os.setf(ios_base::scientific);
|
||||||
|
|
||||||
// capitalise the E marker
|
// Capitalise the E marker
|
||||||
os.setf(ios_base::uppercase);
|
os.setf(ios_base::uppercase);
|
||||||
|
|
||||||
label prec = 0;
|
label prec = 0;
|
||||||
@ -65,11 +76,11 @@ void Foam::nastranSurfaceWriter::formatOS(OFstream& os) const
|
|||||||
switch (writeFormat_)
|
switch (writeFormat_)
|
||||||
{
|
{
|
||||||
case (wfShort):
|
case (wfShort):
|
||||||
case (wfFree):
|
|
||||||
{
|
{
|
||||||
prec = 8 - offset;
|
prec = 8 - offset;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case (wfFree):
|
||||||
case (wfLong):
|
case (wfLong):
|
||||||
{
|
{
|
||||||
prec = 16 - offset;
|
prec = 16 - offset;
|
||||||
@ -84,6 +95,37 @@ void Foam::nastranSurfaceWriter::formatOS(OFstream& os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::nastranSurfaceWriter::writeKeyword
|
||||||
|
(
|
||||||
|
const word& keyword,
|
||||||
|
Ostream& os
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
os.setf(ios_base::left);
|
||||||
|
|
||||||
|
switch (writeFormat_)
|
||||||
|
{
|
||||||
|
case wfShort:
|
||||||
|
{
|
||||||
|
os << setw(8) << keyword;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case wfLong:
|
||||||
|
{
|
||||||
|
os << setw(8) << word(keyword + '*');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case wfFree:
|
||||||
|
{
|
||||||
|
os << keyword;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
os.unsetf(ios_base::left);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::nastranSurfaceWriter::writeCoord
|
void Foam::nastranSurfaceWriter::writeCoord
|
||||||
(
|
(
|
||||||
const point& p,
|
const point& p,
|
||||||
@ -102,19 +144,27 @@ void Foam::nastranSurfaceWriter::writeCoord
|
|||||||
// 8 PS : single point constraints (blank)
|
// 8 PS : single point constraints (blank)
|
||||||
// 9 SEID : super-element ID
|
// 9 SEID : super-element ID
|
||||||
|
|
||||||
|
|
||||||
|
writeKeyword("GRID", os);
|
||||||
|
|
||||||
|
os << separator_;
|
||||||
|
|
||||||
|
os.setf(ios_base::right);
|
||||||
|
|
||||||
|
writeValue(pointI + 1, os);
|
||||||
|
os << separator_;
|
||||||
|
writeValue("", os);
|
||||||
|
os << separator_;
|
||||||
|
writeValue(p.x(), os);
|
||||||
|
os << separator_;
|
||||||
|
writeValue(p.y(), os);
|
||||||
|
os << separator_;
|
||||||
|
|
||||||
switch (writeFormat_)
|
switch (writeFormat_)
|
||||||
{
|
{
|
||||||
case wfShort:
|
case wfShort:
|
||||||
{
|
{
|
||||||
os.setf(ios_base::left);
|
os << setw(8) << p.z()
|
||||||
os << setw(8) << "GRID";
|
|
||||||
os.unsetf(ios_base::left);
|
|
||||||
os.setf(ios_base::right);
|
|
||||||
os << setw(8) << pointI + 1
|
|
||||||
<< " "
|
|
||||||
<< setw(8) << p.x()
|
|
||||||
<< setw(8) << p.y()
|
|
||||||
<< setw(8) << p.z()
|
|
||||||
<< nl;
|
<< nl;
|
||||||
os.unsetf(ios_base::right);
|
os.unsetf(ios_base::right);
|
||||||
|
|
||||||
@ -122,35 +172,19 @@ void Foam::nastranSurfaceWriter::writeCoord
|
|||||||
}
|
}
|
||||||
case wfLong:
|
case wfLong:
|
||||||
{
|
{
|
||||||
os.setf(ios_base::left);
|
os << nl;
|
||||||
os << setw(8) << "GRID*";
|
|
||||||
os.unsetf(ios_base::left);
|
|
||||||
os.setf(ios_base::right);
|
|
||||||
os << setw(16) << pointI + 1
|
|
||||||
<< " "
|
|
||||||
<< setw(16) << p.x()
|
|
||||||
<< setw(16) << p.y()
|
|
||||||
<< nl;
|
|
||||||
os.unsetf(ios_base::right);
|
os.unsetf(ios_base::right);
|
||||||
os.setf(ios_base::left);
|
writeKeyword("", os);
|
||||||
os << setw(8) << "*";
|
|
||||||
os.unsetf(ios_base::left);
|
|
||||||
os.setf(ios_base::right);
|
os.setf(ios_base::right);
|
||||||
os << setw(16) << p.z()
|
writeValue(p.z(), os);
|
||||||
<< nl;
|
os << nl;
|
||||||
os.unsetf(ios_base::right);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wfFree:
|
case wfFree:
|
||||||
{
|
{
|
||||||
os << "GRID"
|
writeValue(p.z(), os);
|
||||||
<< ',' << pointI + 1
|
os << nl;
|
||||||
<< ','
|
|
||||||
<< ',' << p.x()
|
|
||||||
<< ',' << p.y()
|
|
||||||
<< ',' << p.z()
|
|
||||||
<< nl;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -166,8 +200,11 @@ void Foam::nastranSurfaceWriter::writeCoord
|
|||||||
) << "Unknown writeFormat enumeration" << abort(FatalError);
|
) << "Unknown writeFormat enumeration" << abort(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os.unsetf(ios_base::right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::nastranSurfaceWriter::writeFace
|
void Foam::nastranSurfaceWriter::writeFace
|
||||||
(
|
(
|
||||||
const word& faceType,
|
const word& faceType,
|
||||||
@ -190,67 +227,55 @@ void Foam::nastranSurfaceWriter::writeFace
|
|||||||
|
|
||||||
// For CTRIA3 elements, cols 7 onwards are not used
|
// For CTRIA3 elements, cols 7 onwards are not used
|
||||||
|
|
||||||
|
label PID = 1;
|
||||||
|
|
||||||
|
writeKeyword(faceType, os);
|
||||||
|
|
||||||
|
os << separator_;
|
||||||
|
|
||||||
|
os.setf(ios_base::right);
|
||||||
|
|
||||||
|
writeValue(nFace++, os);
|
||||||
|
|
||||||
|
os << separator_;
|
||||||
|
|
||||||
|
writeValue(PID, os);
|
||||||
|
|
||||||
switch (writeFormat_)
|
switch (writeFormat_)
|
||||||
{
|
{
|
||||||
case wfShort:
|
case wfShort:
|
||||||
{
|
{
|
||||||
os.setf(ios_base::left);
|
|
||||||
os << setw(8) << faceType;
|
|
||||||
os.unsetf(ios_base::left);
|
|
||||||
os.setf(ios_base::right);
|
|
||||||
os << setw(8) << nFace++
|
|
||||||
<< " ";
|
|
||||||
|
|
||||||
forAll(facePts, i)
|
forAll(facePts, i)
|
||||||
{
|
{
|
||||||
os << setw(8) << facePts[i] + 1;
|
writeValue(facePts[i] + 1, os);
|
||||||
}
|
}
|
||||||
|
|
||||||
os << nl;
|
|
||||||
os.unsetf(ios_base::right);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wfLong:
|
case wfLong:
|
||||||
{
|
{
|
||||||
os.setf(ios_base::left);
|
|
||||||
os << setw(8) << word(faceType + "*");
|
|
||||||
os.unsetf(ios_base::left);
|
|
||||||
os.setf(ios_base::right);
|
|
||||||
os << setw(16) << nFace++
|
|
||||||
<< " ";
|
|
||||||
|
|
||||||
forAll(facePts, i)
|
forAll(facePts, i)
|
||||||
{
|
{
|
||||||
os << setw(16) << facePts[i] + 1;
|
writeValue(facePts[i] + 1, os);
|
||||||
if (i == 1)
|
if (i == 1)
|
||||||
{
|
{
|
||||||
os << nl;
|
os << nl;
|
||||||
os.unsetf(ios_base::right);
|
os.unsetf(ios_base::right);
|
||||||
os.setf(ios_base::left);
|
writeKeyword("", os);
|
||||||
os << setw(8) << "*";
|
|
||||||
os.unsetf(ios_base::left);
|
|
||||||
os.setf(ios_base::right);
|
os.setf(ios_base::right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
os << nl;
|
|
||||||
os.unsetf(ios_base::right);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wfFree:
|
case wfFree:
|
||||||
{
|
{
|
||||||
os << faceType << ','
|
|
||||||
<< ++nFace << ',';
|
|
||||||
|
|
||||||
forAll(facePts, i)
|
forAll(facePts, i)
|
||||||
{
|
{
|
||||||
os << ',' << facePts[i] + 1;
|
os << separator_;
|
||||||
|
writeValue(facePts[i] + 1, os);
|
||||||
}
|
}
|
||||||
|
|
||||||
os << nl;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -268,6 +293,8 @@ void Foam::nastranSurfaceWriter::writeFace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os << nl;
|
||||||
|
os.unsetf(ios_base::right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -279,7 +306,7 @@ void Foam::nastranSurfaceWriter::writeGeometry
|
|||||||
OFstream& os
|
OFstream& os
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// write points
|
// Write points
|
||||||
|
|
||||||
os << "$" << nl
|
os << "$" << nl
|
||||||
<< "$ Points" << nl
|
<< "$ Points" << nl
|
||||||
@ -291,7 +318,7 @@ void Foam::nastranSurfaceWriter::writeGeometry
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// write faces
|
// Write faces
|
||||||
|
|
||||||
os << "$" << nl
|
os << "$" << nl
|
||||||
<< "$ Faces" << nl
|
<< "$ Faces" << nl
|
||||||
@ -315,7 +342,7 @@ void Foam::nastranSurfaceWriter::writeGeometry
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// decompose poly face into tris
|
// Decompose poly face into tris
|
||||||
label nTri = 0;
|
label nTri = 0;
|
||||||
faceList triFaces;
|
faceList triFaces;
|
||||||
f.triangles(points, nTri, triFaces);
|
f.triangles(points, nTri, triFaces);
|
||||||
@ -330,6 +357,42 @@ void Foam::nastranSurfaceWriter::writeGeometry
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::nastranSurfaceWriter::writeFooter(Ostream& os) const
|
||||||
|
{
|
||||||
|
label PID = 1;
|
||||||
|
|
||||||
|
writeKeyword("PSHELL", os);
|
||||||
|
|
||||||
|
os << separator_;
|
||||||
|
|
||||||
|
writeValue(PID, os);
|
||||||
|
|
||||||
|
for (label i = 0; i < 7; i++)
|
||||||
|
{
|
||||||
|
// Dummy values
|
||||||
|
os << separator_;
|
||||||
|
writeValue(1, os);
|
||||||
|
}
|
||||||
|
|
||||||
|
os << nl;
|
||||||
|
writeKeyword("MAT1", os);
|
||||||
|
os << separator_;
|
||||||
|
|
||||||
|
label MID = 1;
|
||||||
|
|
||||||
|
writeValue(MID, os);
|
||||||
|
|
||||||
|
for (label i = 0; i < 7; i++)
|
||||||
|
{
|
||||||
|
// Dummy values
|
||||||
|
os << separator_;
|
||||||
|
writeValue("", os);
|
||||||
|
}
|
||||||
|
|
||||||
|
os << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::nastranSurfaceWriter::nastranSurfaceWriter()
|
Foam::nastranSurfaceWriter::nastranSurfaceWriter()
|
||||||
@ -346,18 +409,26 @@ Foam::nastranSurfaceWriter::nastranSurfaceWriter(const dictionary& options)
|
|||||||
surfaceWriter(),
|
surfaceWriter(),
|
||||||
writeFormat_(wfLong),
|
writeFormat_(wfLong),
|
||||||
fieldMap_(),
|
fieldMap_(),
|
||||||
scale_(options.lookupOrDefault("scale", 1.0))
|
scale_(options.lookupOrDefault("scale", 1.0)),
|
||||||
|
separator_("")
|
||||||
{
|
{
|
||||||
if (options.found("format"))
|
if (options.found("format"))
|
||||||
{
|
{
|
||||||
writeFormat_ = writeFormatNames_.read(options.lookup("format"));
|
writeFormat_ = writeFormatNames_.read(options.lookup("format"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (writeFormat_ == wfFree)
|
||||||
|
{
|
||||||
|
separator_ = ",";
|
||||||
|
}
|
||||||
|
|
||||||
List<Tuple2<word, word> > fieldSet(options.lookup("fields"));
|
List<Tuple2<word, word> > fieldSet(options.lookup("fields"));
|
||||||
|
|
||||||
forAll(fieldSet, i)
|
forAll(fieldSet, i)
|
||||||
{
|
{
|
||||||
fieldMap_.insert(fieldSet[i].first(), fieldSet[i].second());
|
dataFormat format = dataFormatNames_[fieldSet[i].second()];
|
||||||
|
|
||||||
|
fieldMap_.insert(fieldSet[i].first(), format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,7 +441,7 @@ Foam::nastranSurfaceWriter::~nastranSurfaceWriter()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::nastranSurfaceWriter::write
|
Foam::fileName Foam::nastranSurfaceWriter::write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -384,7 +455,7 @@ void Foam::nastranSurfaceWriter::write
|
|||||||
mkDir(outputDir);
|
mkDir(outputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
OFstream os(outputDir/surfaceName + ".dat");
|
OFstream os(outputDir/surfaceName + ".nas");
|
||||||
formatOS(os);
|
formatOS(os);
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
@ -405,7 +476,11 @@ void Foam::nastranSurfaceWriter::write
|
|||||||
mkDir(outputDir);
|
mkDir(outputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
writeFooter(os);
|
||||||
|
|
||||||
os << "ENDDATA" << endl;
|
os << "ENDDATA" << endl;
|
||||||
|
|
||||||
|
return os.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -32,7 +32,11 @@ Description
|
|||||||
nastran
|
nastran
|
||||||
{
|
{
|
||||||
// From OpenFOAM field name to Nastran field name
|
// From OpenFOAM field name to Nastran field name
|
||||||
fields ((pMean PLOAD2));
|
fields
|
||||||
|
(
|
||||||
|
(pMean PLOAD2)
|
||||||
|
(p PLOAD4)
|
||||||
|
);
|
||||||
// Optional scale
|
// Optional scale
|
||||||
scale 2.0;
|
scale 2.0;
|
||||||
// Optional format
|
// Optional format
|
||||||
@ -52,6 +56,7 @@ SourceFiles
|
|||||||
#include "surfaceWriter.H"
|
#include "surfaceWriter.H"
|
||||||
#include "NamedEnum.H"
|
#include "NamedEnum.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
|
#include "HashTable.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -77,6 +82,14 @@ public:
|
|||||||
|
|
||||||
static const NamedEnum<writeFormat, 3> writeFormatNames_;
|
static const NamedEnum<writeFormat, 3> writeFormatNames_;
|
||||||
|
|
||||||
|
enum dataFormat
|
||||||
|
{
|
||||||
|
dfPLOAD2,
|
||||||
|
dfPLOAD4
|
||||||
|
};
|
||||||
|
|
||||||
|
static const NamedEnum<dataFormat, 2> dataFormatNames_;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -85,12 +98,15 @@ private:
|
|||||||
//- Write option
|
//- Write option
|
||||||
writeFormat writeFormat_;
|
writeFormat writeFormat_;
|
||||||
|
|
||||||
//- Map of OpenFOAM field name vs nastran field name
|
//- Mapping from field name to data format enumeration
|
||||||
HashTable<word> fieldMap_;
|
HashTable<dataFormat, word> fieldMap_;
|
||||||
|
|
||||||
//- Scale to apply to values (default = 1.0)
|
//- Scale to apply to values (default = 1.0)
|
||||||
scalar scale_;
|
scalar scale_;
|
||||||
|
|
||||||
|
//- Separator used for free format
|
||||||
|
word separator_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
@ -123,19 +139,37 @@ private:
|
|||||||
OFstream& os
|
OFstream& os
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
//- Write the formatted keyword to the output stream
|
||||||
|
void writeKeyword
|
||||||
|
(
|
||||||
|
const word& keyword,
|
||||||
|
Ostream& os
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Write the footer information
|
||||||
|
void writeFooter(Ostream& os) const;
|
||||||
|
|
||||||
|
//- Write a formatted value to the output stream
|
||||||
|
template<class Type>
|
||||||
|
void writeValue
|
||||||
|
(
|
||||||
|
const Type& value,
|
||||||
|
Ostream& os
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Write a face-based value
|
//- Write a face-based value
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void writeFaceValue
|
void writeFaceValue
|
||||||
(
|
(
|
||||||
const word& nasFieldName,
|
const dataFormat& format,
|
||||||
const Type& value,
|
const Type& value,
|
||||||
const label EID,
|
const label EID,
|
||||||
OFstream& os
|
Ostream& os
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Templated write operation
|
//- Templated write operation
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void writeTemplate
|
fileName writeTemplate
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -171,13 +205,13 @@ public:
|
|||||||
|
|
||||||
//- True if the surface format supports geometry in a separate file.
|
//- True if the surface format supports geometry in a separate file.
|
||||||
// False if geometry and field must be in a single file
|
// False if geometry and field must be in a single file
|
||||||
virtual bool separateGeometry()
|
virtual bool separateGeometry() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Write single surface geometry to file.
|
//- Write single surface geometry to file.
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -188,7 +222,7 @@ public:
|
|||||||
|
|
||||||
//- Write scalarField for a single surface to file.
|
//- Write scalarField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -202,7 +236,7 @@ public:
|
|||||||
|
|
||||||
//- Write vectorField for a single surface to file.
|
//- Write vectorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -216,7 +250,7 @@ public:
|
|||||||
|
|
||||||
//- Write sphericalTensorField for a single surface to file.
|
//- Write sphericalTensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -230,7 +264,7 @@ public:
|
|||||||
|
|
||||||
//- Write symmTensorField for a single surface to file.
|
//- Write symmTensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -244,7 +278,7 @@ public:
|
|||||||
|
|
||||||
//- Write tensorField for a single surface to file.
|
//- Write tensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -30,92 +30,141 @@ License
|
|||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::nastranSurfaceWriter::writeFaceValue
|
void Foam::nastranSurfaceWriter::writeValue
|
||||||
(
|
(
|
||||||
const word& nasFieldName,
|
|
||||||
const Type& value,
|
const Type& value,
|
||||||
const label EID,
|
Ostream& os
|
||||||
OFstream& os
|
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// Fixed short/long formats:
|
switch (writeFormat_)
|
||||||
// 1 Nastran distributed load type, e.g. PLOAD4
|
{
|
||||||
// 2 SID : load set ID
|
case wfShort:
|
||||||
// 3 EID : element ID
|
{
|
||||||
// 4 onwards: load values
|
os << setw(8) << value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case wfLong:
|
||||||
|
{
|
||||||
|
os << setw(16) << value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case wfFree:
|
||||||
|
{
|
||||||
|
os << value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::nastranSurfaceWriter::writeFaceValue
|
||||||
|
(
|
||||||
|
const dataFormat& format,
|
||||||
|
const Type& value,
|
||||||
|
const label EID,
|
||||||
|
Ostream& os
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Fixed short/long formats supporting PLOAD2 and PLOAD4:
|
||||||
|
|
||||||
|
// PLOAD2:
|
||||||
|
// 1 descriptor : PLOAD2
|
||||||
|
// 2 SID : load set ID
|
||||||
|
// 3 data value : load value - MUST be singular
|
||||||
|
// 4 EID : element ID
|
||||||
|
|
||||||
|
// PLOAD4:
|
||||||
|
// 1 descriptor : PLOAD4
|
||||||
|
// 2 SID : load set ID
|
||||||
|
// 3 EID : element ID
|
||||||
|
// 4 onwards : load values
|
||||||
|
|
||||||
label SID = 1;
|
label SID = 1;
|
||||||
|
|
||||||
Type scaledValue = scale_*value;
|
Type scaledValue = scale_*value;
|
||||||
|
|
||||||
switch (writeFormat_)
|
// Write Keyword
|
||||||
|
writeKeyword(dataFormatNames_[format], os);
|
||||||
|
|
||||||
|
os << separator_;
|
||||||
|
|
||||||
|
// Write load set ID
|
||||||
|
os.setf(ios_base::right);
|
||||||
|
writeValue(SID, os);
|
||||||
|
|
||||||
|
os << separator_;
|
||||||
|
|
||||||
|
switch (format)
|
||||||
{
|
{
|
||||||
case wfShort:
|
case dfPLOAD2:
|
||||||
{
|
{
|
||||||
os.setf(ios_base::left);
|
if (pTraits<Type>::nComponents == 1)
|
||||||
os << setw(8) << nasFieldName;
|
|
||||||
os.unsetf(ios_base::left);
|
|
||||||
os.setf(ios_base::right);
|
|
||||||
os << setw(8) << SID
|
|
||||||
<< setw(8) << EID;
|
|
||||||
|
|
||||||
for (direction dirI = 0; dirI < pTraits<Type>::nComponents; dirI++)
|
|
||||||
{
|
{
|
||||||
os << setw(8) << component(scaledValue, dirI);
|
writeValue(scaledValue, os);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningIn
|
||||||
|
(
|
||||||
|
"template<class Type>"
|
||||||
|
"void Foam::nastranSurfaceWriter::writeNodeValue"
|
||||||
|
"("
|
||||||
|
"const dataFormat&, "
|
||||||
|
"const Type&, "
|
||||||
|
"const label, "
|
||||||
|
"OFstream&"
|
||||||
|
") const"
|
||||||
|
)
|
||||||
|
<< dataFormatNames_[format] << " requires scalar values "
|
||||||
|
<< "and cannot be used for higher rank values"
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
writeValue(scalar(0), os);
|
||||||
}
|
}
|
||||||
|
|
||||||
os.unsetf(ios_base::right);
|
os << separator_;
|
||||||
|
writeValue(EID, os);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wfLong:
|
case dfPLOAD4:
|
||||||
{
|
{
|
||||||
os.setf(ios_base::left);
|
writeValue(EID, os);
|
||||||
os << setw(8) << word(nasFieldName + "*");
|
|
||||||
os.unsetf(ios_base::left);
|
|
||||||
os.setf(ios_base::right);
|
|
||||||
os << setw(16) << SID
|
|
||||||
<< setw(16) << EID;
|
|
||||||
|
|
||||||
for (direction dirI = 0; dirI < pTraits<Type>::nComponents; dirI++)
|
for (direction dirI = 0; dirI < pTraits<Type>::nComponents; dirI++)
|
||||||
{
|
{
|
||||||
os << setw(16) << component(scaledValue, dirI);
|
os << separator_;
|
||||||
|
writeValue(component(scaledValue, dirI), os);
|
||||||
}
|
}
|
||||||
|
|
||||||
os.unsetf(ios_base::right);
|
|
||||||
|
|
||||||
os << nl;
|
|
||||||
|
|
||||||
os.setf(ios_base::left);
|
|
||||||
os << '*';
|
|
||||||
os.unsetf(ios_base::left);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wfFree:
|
|
||||||
{
|
|
||||||
os << nasFieldName << ','
|
|
||||||
<< SID << ','
|
|
||||||
<< EID;
|
|
||||||
|
|
||||||
for (direction dirI = 0; dirI < pTraits<Type>::nComponents; dirI++)
|
|
||||||
{
|
|
||||||
os << ',' << component(scaledValue, dirI);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
WarningIn
|
||||||
|
(
|
||||||
|
"template<class Type>"
|
||||||
|
"void Foam::nastranSurfaceWriter::writeNodeValue"
|
||||||
|
"("
|
||||||
|
"const dataFormat&, "
|
||||||
|
"const Type&, "
|
||||||
|
"const label, "
|
||||||
|
"OFstream&"
|
||||||
|
") const"
|
||||||
|
)
|
||||||
|
<< "Unhandled enumeration " << dataFormatNames_[format]
|
||||||
|
<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os.unsetf(ios_base::right);
|
||||||
|
|
||||||
os << nl;
|
os << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::nastranSurfaceWriter::writeTemplate
|
Foam::fileName Foam::nastranSurfaceWriter::writeTemplate
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -127,6 +176,7 @@ void Foam::nastranSurfaceWriter::writeTemplate
|
|||||||
const bool verbose
|
const bool verbose
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!fieldMap_.found(fieldName))
|
if (!fieldMap_.found(fieldName))
|
||||||
{
|
{
|
||||||
WarningIn
|
WarningIn
|
||||||
@ -148,10 +198,10 @@ void Foam::nastranSurfaceWriter::writeTemplate
|
|||||||
<< fieldMap_
|
<< fieldMap_
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
|
|
||||||
return;
|
return fileName::null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const word& nasFieldName(fieldMap_[fieldName]);
|
const dataFormat& format(fieldMap_[fieldName]);
|
||||||
|
|
||||||
if (!isDir(outputDir/fieldName))
|
if (!isDir(outputDir/fieldName))
|
||||||
{
|
{
|
||||||
@ -161,7 +211,7 @@ void Foam::nastranSurfaceWriter::writeTemplate
|
|||||||
// const scalar timeValue = Foam::name(this->mesh().time().timeValue());
|
// const scalar timeValue = Foam::name(this->mesh().time().timeValue());
|
||||||
const scalar timeValue = 0.0;
|
const scalar timeValue = 0.0;
|
||||||
|
|
||||||
OFstream os(outputDir/fieldName/surfaceName + ".dat");
|
OFstream os(outputDir/fieldName/surfaceName + ".nas");
|
||||||
formatOS(os);
|
formatOS(os);
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
@ -203,7 +253,7 @@ void Foam::nastranSurfaceWriter::writeTemplate
|
|||||||
}
|
}
|
||||||
v /= f.size();
|
v /= f.size();
|
||||||
|
|
||||||
writeFaceValue(nasFieldName, v, ++n, os);
|
writeFaceValue(format, v, ++n, os);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -217,12 +267,16 @@ void Foam::nastranSurfaceWriter::writeTemplate
|
|||||||
|
|
||||||
forAll(dFaces, faceI)
|
forAll(dFaces, faceI)
|
||||||
{
|
{
|
||||||
writeFaceValue(nasFieldName, values[faceI], ++n, os);
|
writeFaceValue(format, values[faceI], ++n, os);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
writeFooter(os);
|
||||||
|
|
||||||
os << "ENDDATA" << endl;
|
os << "ENDDATA" << endl;
|
||||||
|
|
||||||
|
return os.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -56,7 +56,7 @@ Foam::proxySurfaceWriter::~proxySurfaceWriter()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::proxySurfaceWriter::write
|
Foam::fileName Foam::proxySurfaceWriter::write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -68,7 +68,7 @@ void Foam::proxySurfaceWriter::write
|
|||||||
// avoid bad values
|
// avoid bad values
|
||||||
if (ext_.empty())
|
if (ext_.empty())
|
||||||
{
|
{
|
||||||
return;
|
return fileName::null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDir(outputDir))
|
if (!isDir(outputDir))
|
||||||
@ -84,6 +84,8 @@ void Foam::proxySurfaceWriter::write
|
|||||||
}
|
}
|
||||||
|
|
||||||
MeshedSurfaceProxy<face>(points, faces).write(outName);
|
MeshedSurfaceProxy<face>(points, faces).write(outName);
|
||||||
|
|
||||||
|
return outName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -78,14 +78,14 @@ public:
|
|||||||
|
|
||||||
//- True if the surface format supports geometry in a separate file.
|
//- True if the surface format supports geometry in a separate file.
|
||||||
// False if geometry and field must be in a single file
|
// False if geometry and field must be in a single file
|
||||||
virtual bool separateGeometry()
|
virtual bool separateGeometry() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Write single surface geometry to file.
|
//- Write single surface geometry to file.
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -93,7 +93,6 @@ public:
|
|||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
const bool verbose = false
|
const bool verbose = false
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -24,11 +24,6 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "rawSurfaceWriter.H"
|
#include "rawSurfaceWriter.H"
|
||||||
|
|
||||||
#include "OFstream.H"
|
|
||||||
#include "OSspecific.H"
|
|
||||||
#include "IOmanip.H"
|
|
||||||
|
|
||||||
#include "makeSurfaceWriterMethods.H"
|
#include "makeSurfaceWriterMethods.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
@ -208,66 +203,6 @@ namespace Foam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::rawSurfaceWriter::writeTemplate
|
|
||||||
(
|
|
||||||
const fileName& outputDir,
|
|
||||||
const fileName& surfaceName,
|
|
||||||
const pointField& points,
|
|
||||||
const faceList& faces,
|
|
||||||
const word& fieldName,
|
|
||||||
const Field<Type>& values,
|
|
||||||
const bool isNodeValues,
|
|
||||||
const bool verbose
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
if (!isDir(outputDir))
|
|
||||||
{
|
|
||||||
mkDir(outputDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
OFstream os(outputDir/fieldName + '_' + surfaceName + ".raw");
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// header
|
|
||||||
os << "# " << fieldName;
|
|
||||||
if (isNodeValues)
|
|
||||||
{
|
|
||||||
os << " POINT_DATA ";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
os << " FACE_DATA ";
|
|
||||||
}
|
|
||||||
|
|
||||||
// header
|
|
||||||
writeHeader(os, fieldName, values);
|
|
||||||
|
|
||||||
// values
|
|
||||||
if (isNodeValues)
|
|
||||||
{
|
|
||||||
forAll(values, elemI)
|
|
||||||
{
|
|
||||||
writeLocation(os, points, elemI);
|
|
||||||
writeData(os, values[elemI]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
forAll(values, elemI)
|
|
||||||
{
|
|
||||||
writeLocation(os, points, faces, elemI);
|
|
||||||
writeData(os, values[elemI]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::rawSurfaceWriter::rawSurfaceWriter()
|
Foam::rawSurfaceWriter::rawSurfaceWriter()
|
||||||
@ -284,7 +219,7 @@ Foam::rawSurfaceWriter::~rawSurfaceWriter()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::rawSurfaceWriter::write
|
Foam::fileName Foam::rawSurfaceWriter::write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -318,6 +253,8 @@ void Foam::rawSurfaceWriter::write
|
|||||||
}
|
}
|
||||||
|
|
||||||
os << nl;
|
os << nl;
|
||||||
|
|
||||||
|
return os.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -82,7 +82,7 @@ class rawSurfaceWriter
|
|||||||
|
|
||||||
//- Templated write operation
|
//- Templated write operation
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void writeTemplate
|
fileName writeTemplate
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -114,7 +114,7 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Write single surface geometry to file.
|
//- Write single surface geometry to file.
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -126,7 +126,7 @@ public:
|
|||||||
|
|
||||||
//- Write scalarField for a single surface to file.
|
//- Write scalarField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -140,7 +140,7 @@ public:
|
|||||||
|
|
||||||
//- Write vectorField for a single surface to file.
|
//- Write vectorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -154,7 +154,7 @@ public:
|
|||||||
|
|
||||||
//- Write sphericalTensorField for a single surface to file.
|
//- Write sphericalTensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -168,7 +168,7 @@ public:
|
|||||||
|
|
||||||
//- Write symmTensorField for a single surface to file.
|
//- Write symmTensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -182,7 +182,7 @@ public:
|
|||||||
|
|
||||||
//- Write tensorField for a single surface to file.
|
//- Write tensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -193,7 +193,6 @@ public:
|
|||||||
const bool isNodeValues,
|
const bool isNodeValues,
|
||||||
const bool verbose = false
|
const bool verbose = false
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -203,6 +202,12 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "rawSurfaceWriterTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -0,0 +1,93 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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 "OFstream.H"
|
||||||
|
#include "OSspecific.H"
|
||||||
|
#include "IOmanip.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::fileName Foam::rawSurfaceWriter::writeTemplate
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName,
|
||||||
|
const Field<Type>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (!isDir(outputDir))
|
||||||
|
{
|
||||||
|
mkDir(outputDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
OFstream os(outputDir/fieldName + '_' + surfaceName + ".raw");
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// header
|
||||||
|
os << "# " << fieldName;
|
||||||
|
if (isNodeValues)
|
||||||
|
{
|
||||||
|
os << " POINT_DATA ";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os << " FACE_DATA ";
|
||||||
|
}
|
||||||
|
|
||||||
|
// header
|
||||||
|
writeHeader(os, fieldName, values);
|
||||||
|
|
||||||
|
// values
|
||||||
|
if (isNodeValues)
|
||||||
|
{
|
||||||
|
forAll(values, elemI)
|
||||||
|
{
|
||||||
|
writeLocation(os, points, elemI);
|
||||||
|
writeData(os, values[elemI]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
forAll(values, elemI)
|
||||||
|
{
|
||||||
|
writeLocation(os, points, faces, elemI);
|
||||||
|
writeData(os, values[elemI]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return os.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -24,11 +24,7 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "starcdSurfaceWriter.H"
|
#include "starcdSurfaceWriter.H"
|
||||||
|
|
||||||
#include "MeshedSurfaceProxy.H"
|
#include "MeshedSurfaceProxy.H"
|
||||||
#include "OFstream.H"
|
|
||||||
#include "OSspecific.H"
|
|
||||||
|
|
||||||
#include "makeSurfaceWriterMethods.H"
|
#include "makeSurfaceWriterMethods.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
@ -78,50 +74,6 @@ namespace Foam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
inline void Foam::starcdSurfaceWriter::writeData
|
|
||||||
(
|
|
||||||
Ostream& os,
|
|
||||||
const Type& v
|
|
||||||
)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::starcdSurfaceWriter::writeTemplate
|
|
||||||
(
|
|
||||||
const fileName& outputDir,
|
|
||||||
const fileName& surfaceName,
|
|
||||||
const pointField& points,
|
|
||||||
const faceList& faces,
|
|
||||||
const word& fieldName,
|
|
||||||
const Field<Type>& values,
|
|
||||||
const bool isNodeValues,
|
|
||||||
const bool verbose
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
if (!isDir(outputDir))
|
|
||||||
{
|
|
||||||
mkDir(outputDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
OFstream os(outputDir/fieldName + '_' + surfaceName + ".usr");
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// no header, just write values
|
|
||||||
forAll(values, elemI)
|
|
||||||
{
|
|
||||||
os << elemI+1 << ' ';
|
|
||||||
writeData(os, values[elemI]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::starcdSurfaceWriter::starcdSurfaceWriter()
|
Foam::starcdSurfaceWriter::starcdSurfaceWriter()
|
||||||
@ -138,7 +90,7 @@ Foam::starcdSurfaceWriter::~starcdSurfaceWriter()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::starcdSurfaceWriter::write
|
Foam::fileName Foam::starcdSurfaceWriter::write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -160,6 +112,8 @@ void Foam::starcdSurfaceWriter::write
|
|||||||
}
|
}
|
||||||
|
|
||||||
MeshedSurfaceProxy<face>(points, faces).write(outName);
|
MeshedSurfaceProxy<face>(points, faces).write(outName);
|
||||||
|
|
||||||
|
return outName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -77,7 +77,7 @@ class starcdSurfaceWriter
|
|||||||
|
|
||||||
//- Templated write operation
|
//- Templated write operation
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void writeTemplate
|
fileName writeTemplate
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -110,13 +110,13 @@ public:
|
|||||||
|
|
||||||
//- True if the surface format supports geometry in a separate file.
|
//- True if the surface format supports geometry in a separate file.
|
||||||
// False if geometry and field must be in a single file
|
// False if geometry and field must be in a single file
|
||||||
virtual bool separateGeometry()
|
virtual bool separateGeometry() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Write single surface geometry to file.
|
//- Write single surface geometry to file.
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -127,7 +127,7 @@ public:
|
|||||||
|
|
||||||
//- Write scalarField for a single surface to file.
|
//- Write scalarField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -141,7 +141,7 @@ public:
|
|||||||
|
|
||||||
//- Write vectorField for a single surface to file.
|
//- Write vectorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -155,7 +155,7 @@ public:
|
|||||||
|
|
||||||
//- Write sphericalTensorField for a single surface to file.
|
//- Write sphericalTensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -166,7 +166,6 @@ public:
|
|||||||
const bool isNodeValues,
|
const bool isNodeValues,
|
||||||
const bool verbose = false
|
const bool verbose = false
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -176,6 +175,12 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "starcdSurfaceWriterTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -0,0 +1,76 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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 "OFstream.H"
|
||||||
|
#include "OSspecific.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
inline void Foam::starcdSurfaceWriter::writeData
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const Type& v
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::fileName Foam::starcdSurfaceWriter::writeTemplate
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName,
|
||||||
|
const Field<Type>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (!isDir(outputDir))
|
||||||
|
{
|
||||||
|
mkDir(outputDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
OFstream os(outputDir/fieldName + '_' + surfaceName + ".usr");
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// no header, just write values
|
||||||
|
forAll(values, elemI)
|
||||||
|
{
|
||||||
|
os << elemI+1 << ' ';
|
||||||
|
writeData(os, values[elemI]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return os.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -110,13 +110,13 @@ public:
|
|||||||
|
|
||||||
//- True if the surface format supports geometry in a separate file.
|
//- True if the surface format supports geometry in a separate file.
|
||||||
// False if geometry and field must be in a single file
|
// False if geometry and field must be in a single file
|
||||||
virtual bool separateGeometry()
|
virtual bool separateGeometry() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Write single surface geometry to file.
|
//- Write single surface geometry to file.
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -124,11 +124,13 @@ public:
|
|||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
const bool verbose = false
|
const bool verbose = false
|
||||||
) const
|
) const
|
||||||
{}
|
{
|
||||||
|
return fileName::null;
|
||||||
|
}
|
||||||
|
|
||||||
//- Write scalarField for a single surface to file.
|
//- Write scalarField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -139,11 +141,13 @@ public:
|
|||||||
const bool isNodeValues,
|
const bool isNodeValues,
|
||||||
const bool verbose = false
|
const bool verbose = false
|
||||||
) const
|
) const
|
||||||
{}
|
{
|
||||||
|
return fileName::null;
|
||||||
|
}
|
||||||
|
|
||||||
//- Write vectorField for a single surface to file.
|
//- Write vectorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -154,11 +158,13 @@ public:
|
|||||||
const bool isNodeValues,
|
const bool isNodeValues,
|
||||||
const bool verbose = false
|
const bool verbose = false
|
||||||
) const
|
) const
|
||||||
{}
|
{
|
||||||
|
return fileName::null;
|
||||||
|
}
|
||||||
|
|
||||||
//- Write sphericalTensorField for a single surface to file.
|
//- Write sphericalTensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -169,11 +175,13 @@ public:
|
|||||||
const bool isNodeValues,
|
const bool isNodeValues,
|
||||||
const bool verbose = false
|
const bool verbose = false
|
||||||
) const
|
) const
|
||||||
{}
|
{
|
||||||
|
return fileName::null;
|
||||||
|
}
|
||||||
|
|
||||||
//- Write symmTensorField for a single surface to file.
|
//- Write symmTensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -184,11 +192,13 @@ public:
|
|||||||
const bool isNodeValues,
|
const bool isNodeValues,
|
||||||
const bool verbose = false
|
const bool verbose = false
|
||||||
) const
|
) const
|
||||||
{}
|
{
|
||||||
|
return fileName::null;
|
||||||
|
}
|
||||||
|
|
||||||
//- Write tensorField for a single surface to file.
|
//- Write tensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -199,7 +209,9 @@ public:
|
|||||||
const bool isNodeValues,
|
const bool isNodeValues,
|
||||||
const bool verbose = false
|
const bool verbose = false
|
||||||
) const
|
) const
|
||||||
{}
|
{
|
||||||
|
return fileName::null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -24,10 +24,6 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "vtkSurfaceWriter.H"
|
#include "vtkSurfaceWriter.H"
|
||||||
|
|
||||||
#include "OFstream.H"
|
|
||||||
#include "OSspecific.H"
|
|
||||||
|
|
||||||
#include "makeSurfaceWriterMethods.H"
|
#include "makeSurfaceWriterMethods.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
@ -202,69 +198,6 @@ namespace Foam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Write generic field in vtk format
|
|
||||||
template<class Type>
|
|
||||||
void Foam::vtkSurfaceWriter::writeData
|
|
||||||
(
|
|
||||||
Ostream& os,
|
|
||||||
const Field<Type>& values
|
|
||||||
)
|
|
||||||
{
|
|
||||||
os << "1 " << values.size() << " float" << nl;
|
|
||||||
|
|
||||||
forAll(values, elemI)
|
|
||||||
{
|
|
||||||
os << float(0) << nl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::vtkSurfaceWriter::writeTemplate
|
|
||||||
(
|
|
||||||
const fileName& outputDir,
|
|
||||||
const fileName& surfaceName,
|
|
||||||
const pointField& points,
|
|
||||||
const faceList& faces,
|
|
||||||
const word& fieldName,
|
|
||||||
const Field<Type>& values,
|
|
||||||
const bool isNodeValues,
|
|
||||||
const bool verbose
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
if (!isDir(outputDir))
|
|
||||||
{
|
|
||||||
mkDir(outputDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
OFstream os(outputDir/fieldName + '_' + surfaceName + ".vtk");
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
writeGeometry(os, points, faces);
|
|
||||||
|
|
||||||
// start writing data
|
|
||||||
if (isNodeValues)
|
|
||||||
{
|
|
||||||
os << "POINT_DATA ";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
os << "CELL_DATA ";
|
|
||||||
}
|
|
||||||
|
|
||||||
os << values.size() << nl
|
|
||||||
<< "FIELD attributes 1" << nl
|
|
||||||
<< fieldName << " ";
|
|
||||||
|
|
||||||
// Write data
|
|
||||||
writeData(os, values);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::vtkSurfaceWriter::vtkSurfaceWriter()
|
Foam::vtkSurfaceWriter::vtkSurfaceWriter()
|
||||||
@ -281,7 +214,7 @@ Foam::vtkSurfaceWriter::~vtkSurfaceWriter()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::vtkSurfaceWriter::write
|
Foam::fileName Foam::vtkSurfaceWriter::write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -303,6 +236,8 @@ void Foam::vtkSurfaceWriter::write
|
|||||||
}
|
}
|
||||||
|
|
||||||
writeGeometry(os, points, faces);
|
writeGeometry(os, points, faces);
|
||||||
|
|
||||||
|
return os.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -60,7 +60,7 @@ class vtkSurfaceWriter
|
|||||||
|
|
||||||
//- Templated write operation
|
//- Templated write operation
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void writeTemplate
|
fileName writeTemplate
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -72,6 +72,7 @@ class vtkSurfaceWriter
|
|||||||
const bool verbose
|
const bool verbose
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
@ -91,7 +92,7 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Write single surface geometry to file.
|
//- Write single surface geometry to file.
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir,
|
const fileName& outputDir,
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
@ -103,7 +104,7 @@ public:
|
|||||||
|
|
||||||
//- Write scalarField for a single surface to file.
|
//- Write scalarField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -117,7 +118,7 @@ public:
|
|||||||
|
|
||||||
//- Write vectorField for a single surface to file.
|
//- Write vectorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -131,7 +132,7 @@ public:
|
|||||||
|
|
||||||
//- Write sphericalTensorField for a single surface to file.
|
//- Write sphericalTensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -145,7 +146,7 @@ public:
|
|||||||
|
|
||||||
//- Write symmTensorField for a single surface to file.
|
//- Write symmTensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -159,7 +160,7 @@ public:
|
|||||||
|
|
||||||
//- Write tensorField for a single surface to file.
|
//- Write tensorField for a single surface to file.
|
||||||
// One value per face or vertex (isNodeValues = true)
|
// One value per face or vertex (isNodeValues = true)
|
||||||
virtual void write
|
virtual fileName write
|
||||||
(
|
(
|
||||||
const fileName& outputDir, // <case>/surface/TIME
|
const fileName& outputDir, // <case>/surface/TIME
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
@ -180,6 +181,12 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "vtkSurfaceWriterTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -0,0 +1,95 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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 "OFstream.H"
|
||||||
|
#include "OSspecific.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::vtkSurfaceWriter::writeData
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const Field<Type>& values
|
||||||
|
)
|
||||||
|
{
|
||||||
|
os << "1 " << values.size() << " float" << nl;
|
||||||
|
|
||||||
|
forAll(values, elemI)
|
||||||
|
{
|
||||||
|
os << float(0) << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::fileName Foam::vtkSurfaceWriter::writeTemplate
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const word& fieldName,
|
||||||
|
const Field<Type>& values,
|
||||||
|
const bool isNodeValues,
|
||||||
|
const bool verbose
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (!isDir(outputDir))
|
||||||
|
{
|
||||||
|
mkDir(outputDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
OFstream os(outputDir/fieldName + '_' + surfaceName + ".vtk");
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
writeGeometry(os, points, faces);
|
||||||
|
|
||||||
|
// start writing data
|
||||||
|
if (isNodeValues)
|
||||||
|
{
|
||||||
|
os << "POINT_DATA ";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os << "CELL_DATA ";
|
||||||
|
}
|
||||||
|
|
||||||
|
os << values.size() << nl
|
||||||
|
<< "FIELD attributes 1" << nl
|
||||||
|
<< fieldName << " ";
|
||||||
|
|
||||||
|
// Write data
|
||||||
|
writeData(os, values);
|
||||||
|
|
||||||
|
return os.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user