mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -208,7 +208,7 @@ Foam::plane::plane(const dictionary& dict)
|
||||
}
|
||||
else if (planeType == "embeddedPoints")
|
||||
{
|
||||
const dictionary& subDict = dict.subDict("embeddedPoints");
|
||||
const dictionary& subDict = dict.subDict("embeddedPointsDict");
|
||||
|
||||
point point1(subDict.lookup("point1"));
|
||||
point point2(subDict.lookup("point2"));
|
||||
@ -226,11 +226,10 @@ Foam::plane::plane(const dictionary& dict)
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"plane::plane(const dictionary&)",
|
||||
dict
|
||||
) << "Invalid plane type: " << planeType
|
||||
FatalIOErrorIn("plane::plane(const dictionary&)", dict)
|
||||
<< "Invalid plane type: " << planeType << nl
|
||||
<< "Valid options include: planeEquation, embeddedPoints and "
|
||||
<< "pointAndNormal"
|
||||
<< abort(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,7 +191,12 @@ void Foam::FacePostProcessing<CloudType>::write()
|
||||
|
||||
autoPtr<surfaceWriter> writer
|
||||
(
|
||||
surfaceWriter::New(surfaceFormat_)
|
||||
surfaceWriter::New
|
||||
(
|
||||
surfaceFormat_,
|
||||
this->coeffDict().subOrEmptyDict("formatOptions").
|
||||
subOrEmptyDict(surfaceFormat_)
|
||||
)
|
||||
);
|
||||
|
||||
writer->write
|
||||
|
||||
@ -799,7 +799,7 @@ Foam::label Foam::meshSearch::findCell
|
||||
}
|
||||
else
|
||||
{
|
||||
return findCellLinear(location);
|
||||
return findCellLinear(location);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -31,6 +31,7 @@ License
|
||||
#include "sampledSurface.H"
|
||||
#include "mergePoints.H"
|
||||
#include "indirectPrimitivePatch.H"
|
||||
#include "PatchTools.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -224,7 +225,7 @@ void Foam::fieldValues::faceSource::sampledSurfaceFaces(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::faceSource::combineSurfaceGeometry
|
||||
void Foam::fieldValues::faceSource::combineMeshGeometry
|
||||
(
|
||||
faceList& faces,
|
||||
pointField& points
|
||||
@ -345,6 +346,45 @@ void Foam::fieldValues::faceSource::combineSurfaceGeometry
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::faceSource::combineSurfaceGeometry
|
||||
(
|
||||
faceList& faces,
|
||||
pointField& points
|
||||
) const
|
||||
{
|
||||
if (surfacePtr_.valid())
|
||||
{
|
||||
const sampledSurface& s = surfacePtr_();
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// dimension as fraction of mesh bounding box
|
||||
scalar mergeDim = 1e-10*mesh().bounds().mag();
|
||||
|
||||
labelList pointsMap;
|
||||
|
||||
PatchTools::gatherAndMerge
|
||||
(
|
||||
mergeDim,
|
||||
primitivePatch
|
||||
(
|
||||
SubList<face>(s.faces(), s.faces().size()),
|
||||
s.points()
|
||||
),
|
||||
points,
|
||||
faces,
|
||||
pointsMap
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
faces = s.faces();
|
||||
points = s.points();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
|
||||
@ -417,9 +457,16 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
|
||||
|
||||
if (valueOutput_)
|
||||
{
|
||||
const word surfaceFormat(dict.lookup("surfaceFormat"));
|
||||
|
||||
surfaceWriterPtr_.reset
|
||||
(
|
||||
surfaceWriter::New(dict.lookup("surfaceFormat")).ptr()
|
||||
surfaceWriter::New
|
||||
(
|
||||
surfaceFormat,
|
||||
dict.subOrEmptyDict("formatOptions").
|
||||
subOrEmptyDict(surfaceFormat)
|
||||
).ptr()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,7 +204,14 @@ private:
|
||||
//- Set faces according to sampledSurface
|
||||
void sampledSurfaceFaces(const dictionary&);
|
||||
|
||||
//- Combine faces and points from multiple processors
|
||||
//- Combine mesh faces and points from multiple processors
|
||||
void combineMeshGeometry
|
||||
(
|
||||
faceList& faces,
|
||||
pointField& points
|
||||
) const;
|
||||
|
||||
//- Combine surface faces and points from multiple processors
|
||||
void combineSurfaceGeometry
|
||||
(
|
||||
faceList& faces,
|
||||
|
||||
@ -259,7 +259,15 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
|
||||
{
|
||||
faceList faces;
|
||||
pointField points;
|
||||
combineSurfaceGeometry(faces, points);
|
||||
|
||||
if (surfacePtr_.valid())
|
||||
{
|
||||
combineSurfaceGeometry(faces, points);
|
||||
}
|
||||
else
|
||||
{
|
||||
combineMeshGeometry(faces, points);
|
||||
}
|
||||
|
||||
fileName outputDir;
|
||||
if (Pstream::parRun())
|
||||
|
||||
@ -57,11 +57,11 @@ standardRadiation::standardRadiation
|
||||
)
|
||||
:
|
||||
filmRadiationModel(typeName, owner, dict),
|
||||
QrPrimary_
|
||||
QinPrimary_
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Qr", // same name as Qr on primary region to enable mapping
|
||||
"Qin", // same name as Qin on primary region to enable mapping
|
||||
owner.time().timeName(),
|
||||
owner.regionMesh(),
|
||||
IOobject::NO_READ,
|
||||
@ -103,7 +103,7 @@ standardRadiation::~standardRadiation()
|
||||
void standardRadiation::correct()
|
||||
{
|
||||
// Transfer Qr from primary region
|
||||
QrPrimary_.correctBoundaryConditions();
|
||||
QinPrimary_.correctBoundaryConditions();
|
||||
}
|
||||
|
||||
|
||||
@ -128,13 +128,13 @@ tmp<volScalarField> standardRadiation::Shs()
|
||||
);
|
||||
|
||||
scalarField& Shs = tShs();
|
||||
const scalarField& QrP = QrPrimary_.internalField();
|
||||
const scalarField& QinP = QinPrimary_.internalField();
|
||||
const scalarField& delta = delta_.internalField();
|
||||
|
||||
Shs = beta_*(QrP*pos(delta - deltaMin_))*(1.0 - exp(-kappaBar_*delta));
|
||||
Shs = beta_*(QinP*pos(delta - deltaMin_))*(1.0 - exp(-kappaBar_*delta));
|
||||
|
||||
// Update net Qr on local region
|
||||
QrNet_.internalField() = QrP - Shs;
|
||||
QrNet_.internalField() = QinP - Shs;
|
||||
QrNet_.correctBoundaryConditions();
|
||||
|
||||
return tShs;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -59,8 +59,8 @@ private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Radiative flux mapped from the primary region / [kg/s3]
|
||||
volScalarField QrPrimary_;
|
||||
//- Radiative incident flux mapped from the primary region / [kg/s3]
|
||||
volScalarField QinPrimary_;
|
||||
|
||||
//- Remaining radiative flux after removing local contribution
|
||||
volScalarField QrNet_;
|
||||
|
||||
@ -55,6 +55,7 @@ $(surfWriters)/surfaceWriter.C
|
||||
$(surfWriters)/dx/dxSurfaceWriter.C
|
||||
$(surfWriters)/ensight/ensightSurfaceWriter.C
|
||||
$(surfWriters)/foamFile/foamFileSurfaceWriter.C
|
||||
$(surfWriters)/nastran/nastranSurfaceWriter.C
|
||||
$(surfWriters)/proxy/proxySurfaceWriter.C
|
||||
$(surfWriters)/raw/rawSurfaceWriter.C
|
||||
$(surfWriters)/starcd/starcdSurfaceWriter.C
|
||||
|
||||
@ -0,0 +1,372 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "nastranSurfaceWriter.H"
|
||||
#include "IOmanip.H"
|
||||
#include "Tuple2.H"
|
||||
#include "makeSurfaceWriterMethods.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeSurfaceWriterType(nastranSurfaceWriter);
|
||||
addToRunTimeSelectionTable(surfaceWriter, nastranSurfaceWriter, wordDict);
|
||||
|
||||
// create write methods
|
||||
defineSurfaceWriterWriteFields(nastranSurfaceWriter);
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<nastranSurfaceWriter::writeFormat, 3>::names[] =
|
||||
{
|
||||
"short",
|
||||
"long",
|
||||
"free"
|
||||
};
|
||||
|
||||
const NamedEnum<nastranSurfaceWriter::writeFormat, 3>
|
||||
nastranSurfaceWriter::writeFormatNames_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::nastranSurfaceWriter::formatOS(OFstream& os) const
|
||||
{
|
||||
os.setf(ios_base::scientific);
|
||||
|
||||
// capitalise the E marker
|
||||
os.setf(ios_base::uppercase);
|
||||
|
||||
label prec = 0;
|
||||
label offset = 7;
|
||||
switch (writeFormat_)
|
||||
{
|
||||
case (wfShort):
|
||||
case (wfFree):
|
||||
{
|
||||
prec = 8 - offset;
|
||||
break;
|
||||
}
|
||||
case (wfLong):
|
||||
{
|
||||
prec = 16 - offset;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
os.precision(prec);
|
||||
}
|
||||
|
||||
|
||||
void Foam::nastranSurfaceWriter::writeCoord
|
||||
(
|
||||
const point& p,
|
||||
label& nPoint,
|
||||
label& continuation,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Fixed short/long formats:
|
||||
// 1 GRID
|
||||
// 2 ID : point ID
|
||||
// 3 CP : co-ordinate system ID (blank)
|
||||
// 4 X1 : point x cp-ordinate
|
||||
// 5 X2 : point x cp-ordinate
|
||||
// 6 X3 : point x cp-ordinate
|
||||
// 7 CD : co-ordinate system for displacements (blank)
|
||||
// 8 PS : single point constraints (blank)
|
||||
// 9 SEID : super-element ID
|
||||
|
||||
switch (writeFormat_)
|
||||
{
|
||||
case wfShort:
|
||||
{
|
||||
os << setw(8) << "GRID"
|
||||
<< setw(8) << ++nPoint
|
||||
<< " "
|
||||
<< setw(8) << p.x()
|
||||
<< setw(8) << p.y()
|
||||
<< setw(8) << p.z()
|
||||
<< nl;
|
||||
|
||||
break;
|
||||
}
|
||||
case wfLong:
|
||||
{
|
||||
os << setw(8) << "GRID*"
|
||||
<< setw(16) << ++nPoint
|
||||
<< " "
|
||||
<< setw(16) << p.x()
|
||||
<< setw(16) << p.y()
|
||||
<< setw(8) << ++continuation
|
||||
<< nl
|
||||
<< setw(8) << continuation
|
||||
<< setw(16) << p.z()
|
||||
<< nl;
|
||||
|
||||
break;
|
||||
}
|
||||
case wfFree:
|
||||
{
|
||||
os << "GRID"
|
||||
<< ',' << ++nPoint
|
||||
<< ','
|
||||
<< ',' << p.x()
|
||||
<< ',' << p.y()
|
||||
<< ',' << p.z()
|
||||
<< nl;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"void Foam::nastranSurfaceWriter::writeCoord"
|
||||
"("
|
||||
"Ostream&, "
|
||||
"const point&"
|
||||
") const"
|
||||
) << "Unknown writeFormat enumeration" << abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Foam::nastranSurfaceWriter::writeFace
|
||||
(
|
||||
const word& faceType,
|
||||
const labelList& facePts,
|
||||
label& nFace,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Only valid surface elements are CTRIA3 and CQUAD4
|
||||
|
||||
// Fixed short/long formats:
|
||||
// 1 CQUAD4
|
||||
// 2 EID : element ID
|
||||
// 3 PID : property element ID; default = EID (blank)
|
||||
// 4 G1 : grid point index
|
||||
// 5 G2 : grid point index
|
||||
// 6 G3 : grid point index
|
||||
// 7 G4 : grid point index
|
||||
// 8 onwards - not used
|
||||
|
||||
// For CTRIA3 elements, cols 7 onwards are not used
|
||||
|
||||
switch (writeFormat_)
|
||||
{
|
||||
case wfShort:
|
||||
case wfLong:
|
||||
{
|
||||
os << setw(8) << faceType
|
||||
<< setw(8) << ++nFace
|
||||
<< " ";
|
||||
|
||||
forAll(facePts, i)
|
||||
{
|
||||
os << setw(8) << facePts[i];
|
||||
}
|
||||
|
||||
os << nl;
|
||||
|
||||
break;
|
||||
}
|
||||
case wfFree:
|
||||
{
|
||||
os << faceType << ','
|
||||
<< ++nFace << ',';
|
||||
|
||||
forAll(facePts, i)
|
||||
{
|
||||
os << ',' << facePts[i];
|
||||
}
|
||||
|
||||
os << nl;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"void Foam::nastranSurfaceWriter::writeFace"
|
||||
"("
|
||||
"const word&"
|
||||
"const labelList&"
|
||||
"label&"
|
||||
"Ostream&, "
|
||||
") const"
|
||||
) << "Unknown writeFormat enumeration" << abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Foam::nastranSurfaceWriter::writeGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
List<DynamicList<face> >& decomposedFaces,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// write points
|
||||
|
||||
os << "$" << nl
|
||||
<< "$ Points" << nl
|
||||
<< "$" << nl;
|
||||
|
||||
label nPoint = 0;
|
||||
label continuation = 0;
|
||||
|
||||
forAll(points, pointI)
|
||||
{
|
||||
writeCoord(points[pointI], nPoint, continuation, os);
|
||||
}
|
||||
|
||||
|
||||
// write faces
|
||||
|
||||
os << "$" << nl
|
||||
<< "$ Faces" << nl
|
||||
<< "$" << nl;
|
||||
|
||||
label nFace = 0;
|
||||
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
const face& f = faces[faceI];
|
||||
|
||||
if (f.size() == 3)
|
||||
{
|
||||
writeFace("CTRIA3", faces[faceI], nFace, os);
|
||||
decomposedFaces[faceI].append(faces[faceI]);
|
||||
}
|
||||
else if (f.size() == 4)
|
||||
{
|
||||
writeFace("CQUAD4", faces[faceI], nFace, os);
|
||||
decomposedFaces[faceI].append(faces[faceI]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// decompose poly face into tris
|
||||
label nTri = 0;
|
||||
faceList triFaces;
|
||||
f.triangles(points, nTri, triFaces);
|
||||
|
||||
forAll(triFaces, triI)
|
||||
{
|
||||
writeFace("CTRIA3", triFaces[triI], nFace, os);
|
||||
decomposedFaces[faceI].append(triFaces[triI]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::nastranSurfaceWriter::nastranSurfaceWriter()
|
||||
:
|
||||
surfaceWriter(),
|
||||
writeFormat_(wfShort),
|
||||
fieldMap_()
|
||||
{}
|
||||
|
||||
|
||||
Foam::nastranSurfaceWriter::nastranSurfaceWriter(const dictionary& options)
|
||||
:
|
||||
surfaceWriter(),
|
||||
writeFormat_(wfShort),
|
||||
fieldMap_()
|
||||
{
|
||||
if (options.found("format"))
|
||||
{
|
||||
writeFormat_ = writeFormatNames_.read(options.lookup("format"));
|
||||
}
|
||||
|
||||
List<Tuple2<word, word> > fieldSet(options.lookup("fields"));
|
||||
|
||||
forAll(fieldSet, i)
|
||||
{
|
||||
fieldMap_.insert(fieldSet[i].first(), fieldSet[i].second());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::nastranSurfaceWriter::~nastranSurfaceWriter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::nastranSurfaceWriter::write
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
if (!isDir(outputDir))
|
||||
{
|
||||
mkDir(outputDir);
|
||||
}
|
||||
|
||||
OFstream os(outputDir/surfaceName + ".dat");
|
||||
formatOS(os);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Info<< "Writing nastran file to " << os.name() << endl;
|
||||
}
|
||||
|
||||
os << "TITLE=OpeNFOAM " << surfaceName.c_str() << " mesh" << nl
|
||||
<< "$" << nl
|
||||
<< "BEGIN BULK" << nl;
|
||||
|
||||
List<DynamicList<face> > decomposedFaces(faces.size());
|
||||
|
||||
writeGeometry(points, faces, decomposedFaces, os);
|
||||
|
||||
if (!isDir(outputDir))
|
||||
{
|
||||
mkDir(outputDir);
|
||||
}
|
||||
|
||||
os << "ENDDATA" << endl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,260 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::nastranSurfaceWriter
|
||||
|
||||
Description
|
||||
A surface writer for the Nastran file format - both surface mesh and fields
|
||||
|
||||
SourceFiles
|
||||
nastranSurfaceWriter.C
|
||||
nastranSurfaceWriterTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef nastranSurfaceWriter_H
|
||||
#define nastranSurfaceWriter_H
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class nastranSurfaceWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class nastranSurfaceWriter
|
||||
:
|
||||
public surfaceWriter
|
||||
{
|
||||
public:
|
||||
|
||||
enum writeFormat
|
||||
{
|
||||
wfShort,
|
||||
wfLong,
|
||||
wfFree
|
||||
};
|
||||
|
||||
static const NamedEnum<writeFormat, 3> writeFormatNames_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Write option
|
||||
writeFormat writeFormat_;
|
||||
|
||||
//- Map of OpenFOAM field name vs nastran field name
|
||||
HashTable<word> fieldMap_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Initialise the output stream format params
|
||||
void formatOS(OFstream& os) const;
|
||||
|
||||
//- Write a co-ordinate
|
||||
void writeCoord
|
||||
(
|
||||
const point& p,
|
||||
label& nPoint,
|
||||
label& continuation,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
//- Write a face element (CTRIA3 or CQUAD4)
|
||||
void writeFace
|
||||
(
|
||||
const word& faceType,
|
||||
const labelList& facePts,
|
||||
label& nFace,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
//- Main driver to write the surface mesh geometry
|
||||
void writeGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
List<DynamicList<face> >& decomposedFaces,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
//- Write a face-based value
|
||||
template<class Type>
|
||||
void writeFaceValue
|
||||
(
|
||||
const word& nasFieldName,
|
||||
const Type& value,
|
||||
const label EID,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
//- Templated write operation
|
||||
template<class Type>
|
||||
void 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("nastran");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
nastranSurfaceWriter();
|
||||
|
||||
//- Construct with some output options
|
||||
nastranSurfaceWriter(const dictionary& options);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~nastranSurfaceWriter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- True if the surface format supports geometry in a separate file.
|
||||
// False if geometry and field must be in a single file
|
||||
virtual bool separateGeometry()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Write single surface geometry to file.
|
||||
virtual void 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 void write
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const word& fieldName,
|
||||
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 void write
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const word& fieldName,
|
||||
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 void write
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const word& fieldName,
|
||||
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 void write
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const word& fieldName,
|
||||
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 void write
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const word& fieldName,
|
||||
const Field<tensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "nastranSurfaceWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,201 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "OFstream.H"
|
||||
#include "IOmanip.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::nastranSurfaceWriter::writeFaceValue
|
||||
(
|
||||
const word& nasFieldName,
|
||||
const Type& value,
|
||||
const label EID,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Fixed short/long formats:
|
||||
// 1 Nastran distributed load type, e.g. PLOAD4
|
||||
// 2 SID : load set ID
|
||||
// 3 EID : element ID
|
||||
// 4 onwards: load values
|
||||
|
||||
label SID = 0;
|
||||
|
||||
label w = 16;
|
||||
switch (writeFormat_)
|
||||
{
|
||||
case wfShort:
|
||||
{
|
||||
w = 8;
|
||||
}
|
||||
case wfLong:
|
||||
{
|
||||
os << setw(8) << nasFieldName
|
||||
<< setw(8) << SID
|
||||
<< setw(8) << EID;
|
||||
|
||||
for (direction dirI = 0; dirI < pTraits<Type>::nComponents; dirI++)
|
||||
{
|
||||
os << setw(w) << component(value, dirI);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case wfFree:
|
||||
{
|
||||
os << nasFieldName << ','
|
||||
<< SID << ','
|
||||
<< EID;
|
||||
|
||||
for (direction dirI = 0; dirI < pTraits<Type>::nComponents; dirI++)
|
||||
{
|
||||
os << ',' << component(value, dirI);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
os << nl;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::nastranSurfaceWriter::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 (!fieldMap_.found(fieldName))
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"void Foam::nastranSurfaceWriter::writeTemplate"
|
||||
"("
|
||||
"const fileName&, "
|
||||
"const fileName&, "
|
||||
"const pointField&, "
|
||||
"const faceList&, "
|
||||
"const word&, "
|
||||
"const Field<Type>&, "
|
||||
"const bool, "
|
||||
"const bool"
|
||||
") const"
|
||||
)
|
||||
<< "No mapping found between field " << fieldName
|
||||
<< " and corresponding Nastran field. Available types are:"
|
||||
<< fieldMap_
|
||||
<< exit(FatalError);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const word& nasFieldName(fieldMap_[fieldName]);
|
||||
|
||||
if (!isDir(outputDir/fieldName))
|
||||
{
|
||||
mkDir(outputDir/fieldName);
|
||||
}
|
||||
|
||||
// const scalar timeValue = Foam::name(this->mesh().time().timeValue());
|
||||
const scalar timeValue = 0.0;
|
||||
|
||||
OFstream os(outputDir/fieldName/surfaceName + ".dat");
|
||||
formatOS(os);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Info<< "Writing nastran file to " << os.name() << endl;
|
||||
}
|
||||
|
||||
os << "TITLE=OpenFOAM " << surfaceName.c_str() << " " << fieldName
|
||||
<< " data" << nl
|
||||
<< "$" << nl
|
||||
<< "TIME " << timeValue << nl
|
||||
<< "$" << nl
|
||||
<< "BEGIN BULK" << nl;
|
||||
|
||||
List<DynamicList<face> > decomposedFaces(faces.size());
|
||||
|
||||
writeGeometry(points, faces, decomposedFaces, os);
|
||||
|
||||
|
||||
os << "$" << nl
|
||||
<< "$ Field data" << nl
|
||||
<< "$" << nl;
|
||||
|
||||
if (isNodeValues)
|
||||
{
|
||||
label n = 0;
|
||||
|
||||
forAll(decomposedFaces, i)
|
||||
{
|
||||
const DynamicList<face>& dFaces = decomposedFaces[i];
|
||||
forAll(dFaces, faceI)
|
||||
{
|
||||
Type v = pTraits<Type>::zero;
|
||||
const face& f = dFaces[faceI];
|
||||
|
||||
forAll(f, fptI)
|
||||
{
|
||||
v += values[f[fptI]];
|
||||
}
|
||||
|
||||
writeFaceValue(nasFieldName, v, ++n, os);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
label n = 0;
|
||||
|
||||
forAll(decomposedFaces, i)
|
||||
{
|
||||
const DynamicList<face>& dFaces = decomposedFaces[i];
|
||||
|
||||
forAll(dFaces, faceI)
|
||||
{
|
||||
writeFaceValue(nasFieldName, values[faceI], ++n, os);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
os << "ENDDATA" << endl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,6 +25,7 @@ Class
|
||||
Foam::surfaceWriter
|
||||
|
||||
Description
|
||||
Base class for surface writers
|
||||
|
||||
SourceFiles
|
||||
surfaceWriter.C
|
||||
@ -115,7 +116,6 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//- Write single surface geometry to file.
|
||||
virtual void write
|
||||
(
|
||||
@ -127,7 +127,6 @@ public:
|
||||
) const
|
||||
{}
|
||||
|
||||
|
||||
//- Write scalarField for a single surface to file.
|
||||
// One value per face or vertex (isNodeValues = true)
|
||||
virtual void write
|
||||
@ -202,8 +201,6 @@ public:
|
||||
const bool verbose = false
|
||||
) const
|
||||
{}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user