mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: snappyHexMesh. Added leak-path detection.
Detects connections (during refinement) between locationsInsideMesh and locationsOutsideMesh and writes a sampledSet for postprocessing.
This commit is contained in:
@ -52,5 +52,6 @@ $(setWriters)/raw/rawSetWriterRunTime.C
|
||||
$(setWriters)/vtk/vtkSetWriterRunTime.C
|
||||
$(setWriters)/xmgrace/xmgraceSetWriterRunTime.C
|
||||
$(setWriters)/csv/csvSetWriterRunTime.C
|
||||
$(setWriters)/nastran/nastranSetWriterRunTime.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libfileFormats
|
||||
|
||||
228
src/fileFormats/sampledSetWriters/nastran/nastranSetWriter.C
Normal file
228
src/fileFormats/sampledSetWriters/nastran/nastranSetWriter.C
Normal file
@ -0,0 +1,228 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "nastranSetWriter.H"
|
||||
#include "coordSet.H"
|
||||
#include "IOmanip.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::nastranSetWriter<Type>::nastranSetWriter()
|
||||
:
|
||||
writer<Type>()
|
||||
{}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::nastranSetWriter<Type>::~nastranSetWriter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::fileName Foam::nastranSetWriter<Type>::getFileName
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames
|
||||
) const
|
||||
{
|
||||
return this->getBaseName(points, valueSetNames) + ".nas";
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::nastranSetWriter<Type>::write
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames,
|
||||
const List<const Field<Type>*>& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << "TITLE=OpenFOAM "
|
||||
<< this->getBaseName(points, valueSetNames).c_str()
|
||||
<< nl
|
||||
<< "$" << nl
|
||||
<< "BEGIN BULK" << nl;
|
||||
|
||||
forAll(points, pointi)
|
||||
{
|
||||
fileFormats::NASCore::writeKeyword(os, "GRID", fieldFormat::FREE);
|
||||
|
||||
const point& pt = points[pointi];
|
||||
|
||||
//os.setf(std::ios_base::right);
|
||||
//os << setw(8) << pointi+1
|
||||
// << setw(8) << ' '
|
||||
// << setw(8) << float(pt.x())
|
||||
// << setw(8) << float(pt.y())
|
||||
// << setw(8) << float(pt.z())
|
||||
// << nl;
|
||||
//os.unsetf(std::ios_base::right);
|
||||
os << ',' << pointi+1
|
||||
<< ','
|
||||
<< ',' << float(pt.x())
|
||||
<< ',' << float(pt.y())
|
||||
<< ',' << float(pt.z())
|
||||
<< nl;
|
||||
}
|
||||
|
||||
if (false)
|
||||
{
|
||||
// Single track with multiple segments
|
||||
const label nEdges = points.size()-1;
|
||||
for (label edgei = 0; edgei < nEdges; ++edgei)
|
||||
{
|
||||
fileFormats::NASCore::writeKeyword
|
||||
(
|
||||
os,
|
||||
"PLOTEL",
|
||||
fieldFormat::FREE
|
||||
);
|
||||
|
||||
//os.setf(std::ios_base::right);
|
||||
//os << setw(8) << edgei+1
|
||||
// << setw(8) << edgei+1
|
||||
// << setw(8) << edgei+2
|
||||
// << nl;
|
||||
//os.unsetf(std::ios_base::right);
|
||||
os << ',' << edgei+1
|
||||
<< ',' << edgei+1
|
||||
<< ',' << edgei+2
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
os << "ENDDATA" << nl;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::nastranSetWriter<Type>::write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>& tracks,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type>>>& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
if (valueSets.size() != valueSetNames.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Number of variables:" << valueSetNames.size() << endl
|
||||
<< "Number of valueSets:" << valueSets.size()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
if (tracks.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
os << "TITLE=OpenFOAM "
|
||||
<< this->getBaseName(tracks[0], valueSetNames).c_str()
|
||||
<< nl
|
||||
<< "$" << nl
|
||||
<< "BEGIN BULK" << nl;
|
||||
|
||||
// label nTracks = tracks.size();
|
||||
// label nPoints = 0;
|
||||
// forAll(tracks, i)
|
||||
// {
|
||||
// nPoints += tracks[i].size();
|
||||
// }
|
||||
|
||||
label globalPti = 0;
|
||||
forAll(tracks, tracki)
|
||||
{
|
||||
const coordSet& points = tracks[tracki];
|
||||
forAll(points, pointi)
|
||||
{
|
||||
fileFormats::NASCore::writeKeyword(os, "GRID", fieldFormat::FREE);
|
||||
|
||||
const point& pt = points[pointi];
|
||||
|
||||
//os.setf(std::ios_base::right);
|
||||
//os << setw(8) << globalPti++
|
||||
// << setw(8) << ' '
|
||||
// << setw(8) << float(pt.x())
|
||||
// << setw(8) << float(pt.y())
|
||||
// << setw(8) << float(pt.z())
|
||||
// << nl;
|
||||
//os.unsetf(std::ios_base::right);
|
||||
os << ',' << globalPti++
|
||||
<< ','
|
||||
<< ',' << float(pt.x())
|
||||
<< ',' << float(pt.y())
|
||||
<< ',' << float(pt.z())
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
if (writeTracks)
|
||||
{
|
||||
// Write ids of track points to file
|
||||
label globalEdgei = 0;
|
||||
label globalPointi = 0;
|
||||
forAll(tracks, tracki)
|
||||
{
|
||||
const coordSet& points = tracks[tracki];
|
||||
|
||||
const label nEdges = points.size()-1;
|
||||
for (label edgei = 0; edgei < nEdges; ++edgei)
|
||||
{
|
||||
fileFormats::NASCore::writeKeyword
|
||||
(
|
||||
os,
|
||||
"PLOTEL",
|
||||
fieldFormat::FREE
|
||||
);
|
||||
|
||||
//os.setf(std::ios_base::right);
|
||||
//os << setw(8) << globalEdgei+1
|
||||
// << setw(8) << globalPointi+1
|
||||
// << setw(8) << globalPointi+2
|
||||
// << nl;
|
||||
//os.unsetf(std::ios_base::right);
|
||||
|
||||
os << ',' << globalEdgei+1
|
||||
<< ',' << globalPointi+1
|
||||
<< ',' << globalPointi+2
|
||||
<< nl;
|
||||
globalEdgei++;
|
||||
globalPointi++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
os << "ENDDATA" << nl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
131
src/fileFormats/sampledSetWriters/nastran/nastranSetWriter.H
Normal file
131
src/fileFormats/sampledSetWriters/nastran/nastranSetWriter.H
Normal file
@ -0,0 +1,131 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::nastranSetWriter
|
||||
|
||||
Description
|
||||
Line format in Nastran (currently hardcoded to 'free' format)
|
||||
|
||||
Does not do field data.
|
||||
|
||||
SourceFiles
|
||||
nastranSetWriter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef nastranSetWriter_H
|
||||
#define nastranSetWriter_H
|
||||
|
||||
#include "writer.H"
|
||||
#include "NASCore.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class nastranSetWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class nastranSetWriter
|
||||
:
|
||||
public writer<Type>
|
||||
{
|
||||
public:
|
||||
|
||||
//- File field formats
|
||||
using fieldFormat = Foam::fileFormats::NASCore::fieldFormat;
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Write the formatted keyword to the output stream
|
||||
Ostream& writeKeyword
|
||||
(
|
||||
Ostream& os,
|
||||
const word& keyword
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("nastran");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
nastranSetWriter();
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~nastranSetWriter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual fileName getFileName
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&,
|
||||
const List<const Field<Type>*>&,
|
||||
Ostream&
|
||||
) const;
|
||||
|
||||
virtual void write
|
||||
(
|
||||
const bool writeTracks,
|
||||
const PtrList<coordSet>&,
|
||||
const wordList& valueSetNames,
|
||||
const List<List<Field<Type>>>&,
|
||||
Ostream&
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "nastranSetWriter.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,37 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "nastranSetWriter.H"
|
||||
#include "writers.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeSetWriters(nastranSetWriter);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user