mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Updates
This commit is contained in:
@ -1,24 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
axis
|
||||
{
|
||||
type word;
|
||||
description "Form of distance data";
|
||||
default distance;
|
||||
valueList
|
||||
(
|
||||
distance
|
||||
x
|
||||
y
|
||||
z
|
||||
xyz
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,21 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
cloud
|
||||
{
|
||||
type dictionary;
|
||||
description "Samples a set of specified points";
|
||||
entries
|
||||
{
|
||||
include "name.cfg";
|
||||
include "axis.cfg";
|
||||
include "points.cfg";
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,21 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
curve
|
||||
{
|
||||
type dictionary;
|
||||
description "Samples a set of specified points that are tracked along a curve";
|
||||
entries
|
||||
{
|
||||
include "name.cfg";
|
||||
include "axis.cfg";
|
||||
include "points.cfg";
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,15 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
end
|
||||
{
|
||||
type vector;
|
||||
description "End point on sampling line";
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,22 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
face
|
||||
{
|
||||
type dictionary;
|
||||
description "One sampling point per face intersection";
|
||||
entries
|
||||
{
|
||||
include "name.cfg";
|
||||
include "axis.cfg";
|
||||
include "start.cfg";
|
||||
include "end.cfg";
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,22 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
midPoint
|
||||
{
|
||||
type dictionary;
|
||||
description "One sampling point per cell, between two face intersections";
|
||||
entries
|
||||
{
|
||||
include "name.cfg";
|
||||
include "axis.cfg";
|
||||
include "start.cfg";
|
||||
include "end.cfg";
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,22 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
midPointAndFace
|
||||
{
|
||||
type dictionary;
|
||||
description "One sampling point per intersected face and one per cell, between two face intersections";
|
||||
entries
|
||||
{
|
||||
include "name.cfg";
|
||||
include "axis.cfg";
|
||||
include "start.cfg";
|
||||
include "end.cfg";
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,15 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
nPoints
|
||||
{
|
||||
type label;
|
||||
description "Number of points on sampling line";
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,15 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
name
|
||||
{
|
||||
type word;
|
||||
description "Name of sampling set";
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,16 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
points
|
||||
{
|
||||
type list;
|
||||
description "List of points to be sampled";
|
||||
elementType vector;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,71 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
// sample tool definition
|
||||
|
||||
description "Line sampling";
|
||||
|
||||
sampleDict
|
||||
{
|
||||
type dictionary;
|
||||
description "sample control dictionary";
|
||||
dictionaryPath "system";
|
||||
|
||||
entries
|
||||
{
|
||||
arguments
|
||||
{
|
||||
type rootCaseTimeArguments;
|
||||
}
|
||||
|
||||
interpolationScheme
|
||||
{
|
||||
type word;
|
||||
description "Sampling interpolation scheme";
|
||||
default cellPoint;
|
||||
valueList
|
||||
(
|
||||
cell
|
||||
cellPoint
|
||||
cellPointFace
|
||||
);
|
||||
}
|
||||
|
||||
writeFormat
|
||||
{
|
||||
type word;
|
||||
description "Output format of data";
|
||||
default raw;
|
||||
valueList
|
||||
(
|
||||
raw
|
||||
gnuplot
|
||||
xmgr
|
||||
jplot
|
||||
);
|
||||
}
|
||||
|
||||
sampleSets
|
||||
{
|
||||
type list;
|
||||
description "List of sampling sets";
|
||||
elementType
|
||||
{
|
||||
include "sampleSet.cfg";
|
||||
}
|
||||
}
|
||||
|
||||
fields
|
||||
{
|
||||
type list;
|
||||
description "List of fields to be sampled";
|
||||
elementType word;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,23 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
sampleSet
|
||||
{
|
||||
type selection;
|
||||
entries
|
||||
{
|
||||
include "uniform.cfg";
|
||||
include "face.cfg";
|
||||
include "midPoint.cfg";
|
||||
include "midPointAndFace.cfg";
|
||||
include "curve.cfg";
|
||||
include "cloud.cfg";
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,15 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
start
|
||||
{
|
||||
type vector;
|
||||
description "Start point on sampling line";
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,43 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
tensorFieldSample
|
||||
{
|
||||
type compound;
|
||||
description "Tensor field to be sampled";
|
||||
entries
|
||||
{
|
||||
name
|
||||
{
|
||||
type word;
|
||||
description "Field name";
|
||||
}
|
||||
|
||||
component
|
||||
{
|
||||
type word;
|
||||
description "Tensor component(s)";
|
||||
valueList
|
||||
(
|
||||
xx
|
||||
xy
|
||||
xz
|
||||
yx
|
||||
yy
|
||||
yz
|
||||
zx
|
||||
zy
|
||||
zz
|
||||
mag
|
||||
full
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,23 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
uniform
|
||||
{
|
||||
type dictionary;
|
||||
description "Uniform distribution of points on a line";
|
||||
entries
|
||||
{
|
||||
include "name.cfg";
|
||||
include "axis.cfg";
|
||||
include "start.cfg";
|
||||
include "end.cfg";
|
||||
include "nPoints.cfg";
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,37 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
vectorFieldSample
|
||||
{
|
||||
type compound;
|
||||
description "Vector field to be sampled";
|
||||
entries
|
||||
{
|
||||
name
|
||||
{
|
||||
type word;
|
||||
description "Field name";
|
||||
}
|
||||
|
||||
component
|
||||
{
|
||||
type word;
|
||||
description "Vector component(s)";
|
||||
valueList
|
||||
(
|
||||
x
|
||||
y
|
||||
z
|
||||
mag
|
||||
full
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,19 +0,0 @@
|
||||
combineSampleSets.C
|
||||
sample.C
|
||||
|
||||
writers/writer/writers.C
|
||||
writers/xmgr/xmgrWriters.C
|
||||
writers/gnuplot/gnuplotWriters.C
|
||||
writers/jplot/jplotWriters.C
|
||||
writers/raw/rawWriters.C
|
||||
|
||||
sampleSets/coordSet/coordSet.C
|
||||
sampleSets/sampleSet/sampleSet.C
|
||||
sampleSets/cloud/cloudSet.C
|
||||
sampleSets/face/faceOnlySet.C
|
||||
sampleSets/curve/curveSet.C
|
||||
sampleSets/uniform/uniformSet.C
|
||||
sampleSets/midPoint/midPointSet.C
|
||||
sampleSets/midPointAndFace/midPointAndFaceSet.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/sample
|
||||
@ -1,120 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "Pstream.H"
|
||||
#include "ListListOps.H"
|
||||
#include "combineSampleSets.H"
|
||||
#include "SortableList.H"
|
||||
#include "IndirectList.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Combine points from all processors. Sort by curveDist and produce
|
||||
// index list. Valid result only on master processor.
|
||||
void combineSampleSets
|
||||
(
|
||||
const PtrList<sampleSet>& sampleSets,
|
||||
PtrList<coordSet>& masterSampleSets,
|
||||
labelListList& indexSets
|
||||
)
|
||||
{
|
||||
forAll(sampleSets, setI)
|
||||
{
|
||||
const sampleSet& samplePts = sampleSets[setI];
|
||||
|
||||
// Collect data from all processors
|
||||
List<List<point> > gatheredPts(Pstream::nProcs());
|
||||
gatheredPts[Pstream::myProcNo()] = samplePts;
|
||||
Pstream::gatherList(gatheredPts);
|
||||
|
||||
List<labelList> gatheredSegments(Pstream::nProcs());
|
||||
gatheredSegments[Pstream::myProcNo()] = samplePts.segments();
|
||||
Pstream::gatherList(gatheredSegments);
|
||||
|
||||
List<scalarList> gatheredDist(Pstream::nProcs());
|
||||
gatheredDist[Pstream::myProcNo()] = samplePts.curveDist();
|
||||
Pstream::gatherList(gatheredDist);
|
||||
|
||||
|
||||
// Combine processor lists into one big list.
|
||||
List<point> allPts
|
||||
(
|
||||
ListListOps::combine<List<point> >
|
||||
(
|
||||
gatheredPts, accessOp<List<point> >()
|
||||
)
|
||||
);
|
||||
labelList allSegments
|
||||
(
|
||||
ListListOps::combine<labelList>
|
||||
(
|
||||
gatheredSegments, accessOp<labelList>()
|
||||
)
|
||||
);
|
||||
scalarList allCurveDist
|
||||
(
|
||||
ListListOps::combine<scalarList>
|
||||
(
|
||||
gatheredDist, accessOp<scalarList>()
|
||||
)
|
||||
);
|
||||
|
||||
// Sort curveDist and use to fill masterSamplePts
|
||||
SortableList<scalar> sortedDist(allCurveDist);
|
||||
indexSets[setI] = sortedDist.indices();
|
||||
|
||||
// Get reference point (note: only master has all points)
|
||||
point refPt;
|
||||
|
||||
if (allPts.size() > 0)
|
||||
{
|
||||
refPt = samplePts.getRefPoint(allPts);
|
||||
}
|
||||
else
|
||||
{
|
||||
refPt = vector::zero;
|
||||
}
|
||||
|
||||
|
||||
masterSampleSets.set
|
||||
(
|
||||
setI,
|
||||
new coordSet
|
||||
(
|
||||
samplePts.name(),
|
||||
samplePts.axis(),
|
||||
IndirectList<point>(allPts, indexSets[setI]),
|
||||
refPt
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,60 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::combineSampleSets
|
||||
|
||||
Description
|
||||
Various utility functions for collection of samples on processors.
|
||||
|
||||
SourceFiles
|
||||
combineSampleSets.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef combineSampleSets_H
|
||||
#define combineSampleSets_H
|
||||
|
||||
#include "labelList.H"
|
||||
#include "PtrList.H"
|
||||
#include "coordSet.H"
|
||||
#include "sampleSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Combine points from all processors. Sort by curveDist and produce
|
||||
// index list. Valid result only on master processor.
|
||||
void combineSampleSets
|
||||
(
|
||||
const Foam::PtrList<Foam::sampleSet>& sampleSets,
|
||||
Foam::PtrList<Foam::coordSet>& masterSampleSets,
|
||||
Foam::labelListList& indexSets
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,86 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "combineSampleValues.H"
|
||||
#include "Pstream.H"
|
||||
#include "ListListOps.H"
|
||||
#include "IndirectList.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Combine values from all processors. Valid result only on master processor.
|
||||
template<class T>
|
||||
void combineSampleValues
|
||||
(
|
||||
const PtrList<volFieldSampler<T> >& sampledFields,
|
||||
const labelListList& indexSets,
|
||||
PtrList<volFieldSampler<T> >& masterFields
|
||||
)
|
||||
{
|
||||
forAll(sampledFields, fieldI)
|
||||
{
|
||||
List<Field<T> > masterValues(indexSets.size());
|
||||
|
||||
forAll(indexSets, setI)
|
||||
{
|
||||
// Collect data from all processors
|
||||
List<Field<T> > gatheredData(Pstream::nProcs());
|
||||
gatheredData[Pstream::myProcNo()] = sampledFields[fieldI][setI];
|
||||
Pstream::gatherList(gatheredData);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
Field<T> allData
|
||||
(
|
||||
ListListOps::combine<Field<T> >
|
||||
(
|
||||
gatheredData,
|
||||
Foam::accessOp<Field<T> >()
|
||||
)
|
||||
);
|
||||
|
||||
masterValues[setI] =
|
||||
IndirectList<T>(allData, indexSets[setI])();
|
||||
}
|
||||
}
|
||||
masterFields.set
|
||||
(
|
||||
fieldI,
|
||||
new volFieldSampler<T>
|
||||
(
|
||||
masterValues,
|
||||
sampledFields[fieldI].name()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::combineSampleValues
|
||||
|
||||
Description
|
||||
Various utility functions for collection of samples on processors.
|
||||
|
||||
SourceFiles
|
||||
combineSampleValues.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef combineSampleValues_H
|
||||
#define combineSampleValues_H
|
||||
|
||||
#include "labelList.H"
|
||||
#include "PtrList.H"
|
||||
#include "volFieldSampler.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Combine values from all processors. Valid result only on master processor.
|
||||
template<class T>
|
||||
void combineSampleValues
|
||||
(
|
||||
const Foam::PtrList<Foam::volFieldSampler<T> >& sampledFields,
|
||||
const Foam::labelListList& indexSets,
|
||||
Foam::PtrList<Foam::volFieldSampler<T> >& masterFields
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "combineSampleValues.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,887 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
Sample field data with a choice of interpolation schemes, sampling options
|
||||
and write formats.
|
||||
|
||||
interpolationScheme : choice of
|
||||
cell : use cell-centre value only; constant over cells
|
||||
cellPoint : use cell-centre and vertex values
|
||||
cellPointFace : use cell-centre, vertex and face values.
|
||||
|
||||
sample: choice of
|
||||
uniform evenly distributed points on line
|
||||
face one point per face intersection
|
||||
midPoint one point per cell, inbetween two face intersections
|
||||
midPointAndFace combination of face and midPoint
|
||||
|
||||
curve specified points, not nessecary on line, uses
|
||||
tracking
|
||||
cloud specified points, uses findCell
|
||||
|
||||
writeFormat : choice of
|
||||
xmgr
|
||||
jplot
|
||||
gnuplot
|
||||
raw
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Pstream.H"
|
||||
#include "argList.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
#include "Cloud.H"
|
||||
#include "passiveParticle.H"
|
||||
#include "meshSearch.H"
|
||||
#include "interpolation.H"
|
||||
#include "volPointInterpolation.H"
|
||||
|
||||
#include "writer.H"
|
||||
#include "sampleSet.H"
|
||||
#include "volFieldSampler.H"
|
||||
#include "dictionaryEntry.H"
|
||||
|
||||
#include "combineSampleSets.H"
|
||||
#include "combineSampleValues.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
template<class Type>
|
||||
void writeSampleFile
|
||||
(
|
||||
const coordSet& masterSampleSet,
|
||||
const PtrList<volFieldSampler<Type> >& masterFields,
|
||||
const label setI,
|
||||
const fileName& timeDir,
|
||||
const word& writeFormat
|
||||
)
|
||||
{
|
||||
if (masterFields.size() > 0)
|
||||
{
|
||||
wordList valueSetNames(masterFields.size());
|
||||
List<const Field<Type>*> valueSets(masterFields.size());
|
||||
|
||||
forAll(masterFields, fieldI)
|
||||
{
|
||||
valueSetNames[fieldI] = masterFields[fieldI].name();
|
||||
valueSets[fieldI] = &masterFields[fieldI][setI];
|
||||
}
|
||||
|
||||
autoPtr<writer<Type> > formatter
|
||||
(
|
||||
writer<Type>::New(writeFormat)
|
||||
);
|
||||
|
||||
fileName fName
|
||||
(
|
||||
timeDir/formatter().getFileName(masterSampleSet, valueSetNames)
|
||||
);
|
||||
|
||||
Info<< "Writing fields to " << fName << endl;
|
||||
|
||||
formatter().write
|
||||
(
|
||||
masterSampleSet,
|
||||
valueSetNames,
|
||||
valueSets,
|
||||
OFstream(fName)()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "addTimeOptions.H"
|
||||
# include "setRootCase.H"
|
||||
|
||||
# include "createTime.H"
|
||||
|
||||
// Get times list
|
||||
instantList Times = runTime.times();
|
||||
|
||||
// set startTime and endTime depending on -time and -latestTime options
|
||||
# include "checkTimeOptions.H"
|
||||
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
|
||||
# include "createMesh.H"
|
||||
|
||||
//
|
||||
// Hack: initialize Cloud to initialize the processor table so from
|
||||
// now on we can use cloud on single processors only.
|
||||
//
|
||||
Cloud<passiveParticle> dummyCloud(mesh, IDLList<passiveParticle>());
|
||||
|
||||
// Read control dictionary
|
||||
IOdictionary sampleDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"sampleDict",
|
||||
runTime.system(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
const word interpolationScheme(sampleDict.lookup("interpolationScheme"));
|
||||
const wordList fieldNames = sampleDict.lookup("fields");
|
||||
|
||||
//
|
||||
// Construct writers
|
||||
//
|
||||
|
||||
word writeFormat(sampleDict.lookup("writeFormat"));
|
||||
|
||||
//
|
||||
// Construct interpolation dictionary (same interpolation for all fields)
|
||||
//
|
||||
|
||||
dictionary interpolationSchemes;
|
||||
|
||||
forAll(fieldNames, fieldI)
|
||||
{
|
||||
interpolationSchemes.add
|
||||
(
|
||||
fieldNames[fieldI],
|
||||
interpolationScheme
|
||||
);
|
||||
}
|
||||
|
||||
// Set up interpolation
|
||||
autoPtr<pointMesh> pMeshPtr(new pointMesh(mesh));
|
||||
autoPtr<volPointInterpolation> pInterpPtr
|
||||
(
|
||||
new volPointInterpolation(mesh, pMeshPtr())
|
||||
);
|
||||
|
||||
// Set up mesh searching
|
||||
meshSearch searchEngine(mesh, true);
|
||||
|
||||
|
||||
fileName samplePath;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
samplePath = runTime.path()/".."/"samples";
|
||||
}
|
||||
else
|
||||
{
|
||||
samplePath = runTime.path()/"samples";
|
||||
}
|
||||
|
||||
if (exists(samplePath))
|
||||
{
|
||||
Info<< "Deleting samples/ directory" << endl << endl;
|
||||
rmDir(samplePath);
|
||||
}
|
||||
}
|
||||
|
||||
fileName oldPointsDir("constant");
|
||||
|
||||
for (label i=startTime; i<endTime; i++)
|
||||
{
|
||||
runTime.setTime(Times[i], i);
|
||||
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
//
|
||||
// Handle geometry/topology changes
|
||||
//
|
||||
polyMesh::readUpdateState state = mesh.readUpdate();
|
||||
|
||||
if
|
||||
(
|
||||
state == polyMesh::POINTS_MOVED
|
||||
|| state == polyMesh::TOPO_CHANGE
|
||||
)
|
||||
{
|
||||
// Geometry and topology changes
|
||||
searchEngine.correct();
|
||||
|
||||
pMeshPtr.reset(new pointMesh(mesh));
|
||||
|
||||
pInterpPtr.reset(new volPointInterpolation(mesh, pMeshPtr()));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Construct sampling point generators
|
||||
//
|
||||
|
||||
PtrList<sampleSet> sampleSets
|
||||
(
|
||||
sampleDict.lookup("sampleSets"),
|
||||
sampleSet::iNew(mesh, searchEngine)
|
||||
);
|
||||
if (sampleSets.size() < 1)
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "No sampleSets provided in sampleDict"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Storage for interpolated values
|
||||
PtrList<volFieldSampler<scalar> > sampledScalarFields
|
||||
(
|
||||
fieldNames.size()
|
||||
);
|
||||
PtrList<volFieldSampler<vector> > sampledVectorFields
|
||||
(
|
||||
fieldNames.size()
|
||||
);
|
||||
PtrList<volFieldSampler<sphericalTensor> > sampledSphericalTensorFields
|
||||
(
|
||||
fieldNames.size()
|
||||
);
|
||||
PtrList<volFieldSampler<symmTensor> > sampledSymmTensorFields
|
||||
(
|
||||
fieldNames.size()
|
||||
);
|
||||
PtrList<volFieldSampler<tensor> > sampledTensorFields
|
||||
(
|
||||
fieldNames.size()
|
||||
);
|
||||
|
||||
//
|
||||
// Do actual interpolation
|
||||
//
|
||||
|
||||
label nScalarFields = 0;
|
||||
label nVectorFields = 0;
|
||||
label nSphericalTensorFields = 0;
|
||||
label nSymmTensorFields = 0;
|
||||
label nTensorFields = 0;
|
||||
|
||||
forAll(fieldNames, fieldI)
|
||||
{
|
||||
const word& fieldName = fieldNames[fieldI];
|
||||
|
||||
IOobject fieldHeader
|
||||
(
|
||||
fieldName,
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
// Determine number of processor actually having this field
|
||||
label fieldFound = (fieldHeader.headerOk() ? 1 : 0);
|
||||
reduce(fieldFound, sumOp<label>());
|
||||
|
||||
if (fieldFound == Pstream::nProcs())
|
||||
{
|
||||
if
|
||||
(
|
||||
fieldHeader.headerClassName() == volScalarField::typeName
|
||||
)
|
||||
{
|
||||
Info<< "Sampling " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volScalarField sField(fieldHeader, mesh);
|
||||
|
||||
sampledScalarFields.set
|
||||
(
|
||||
nScalarFields,
|
||||
new volFieldSampler<scalar>
|
||||
(
|
||||
pInterpPtr(),
|
||||
interpolationSchemes,
|
||||
sField,
|
||||
sampleSets
|
||||
)
|
||||
);
|
||||
|
||||
nScalarFields++;
|
||||
}
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerClassName() == volVectorField::typeName
|
||||
)
|
||||
{
|
||||
Info<< "Sampling " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volVectorField vField(fieldHeader, mesh);
|
||||
|
||||
sampledVectorFields.set
|
||||
(
|
||||
nVectorFields,
|
||||
new volFieldSampler<vector>
|
||||
(
|
||||
pInterpPtr(),
|
||||
interpolationSchemes,
|
||||
vField,
|
||||
sampleSets
|
||||
)
|
||||
);
|
||||
|
||||
nVectorFields++;
|
||||
}
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerClassName()
|
||||
== volSphericalTensorField::typeName
|
||||
)
|
||||
{
|
||||
Info<< "Sampling " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volSphericalTensorField tField(fieldHeader, mesh);
|
||||
|
||||
sampledSphericalTensorFields.set
|
||||
(
|
||||
nSphericalTensorFields,
|
||||
new volFieldSampler<sphericalTensor>
|
||||
(
|
||||
pInterpPtr(),
|
||||
interpolationSchemes,
|
||||
tField,
|
||||
sampleSets
|
||||
)
|
||||
);
|
||||
|
||||
nSphericalTensorFields++;
|
||||
}
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerClassName()
|
||||
== volSymmTensorField::typeName
|
||||
)
|
||||
{
|
||||
Info<< "Sampling " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volSymmTensorField tField(fieldHeader, mesh);
|
||||
|
||||
sampledSymmTensorFields.set
|
||||
(
|
||||
nSymmTensorFields,
|
||||
new volFieldSampler<symmTensor>
|
||||
(
|
||||
pInterpPtr(),
|
||||
interpolationSchemes,
|
||||
tField,
|
||||
sampleSets
|
||||
)
|
||||
);
|
||||
|
||||
nSymmTensorFields++;
|
||||
}
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerClassName() == volTensorField::typeName
|
||||
)
|
||||
{
|
||||
Info<< "Sampling " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volTensorField tField(fieldHeader, mesh);
|
||||
|
||||
sampledTensorFields.set
|
||||
(
|
||||
nTensorFields,
|
||||
new volFieldSampler<tensor>
|
||||
(
|
||||
pInterpPtr(),
|
||||
interpolationSchemes,
|
||||
tField,
|
||||
sampleSets
|
||||
)
|
||||
);
|
||||
|
||||
nTensorFields++;
|
||||
}
|
||||
}
|
||||
else if (fieldFound != 0)
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Did not find field " << fieldName
|
||||
<< " on all processors" << exit(FatalError);
|
||||
}
|
||||
else if (fieldName.find('(') != string::npos)
|
||||
{
|
||||
if (fieldName.find("component") != string::npos)
|
||||
{
|
||||
string baseFieldName(fieldName(0, fieldName.find('.')));
|
||||
|
||||
IOobject fieldHeader
|
||||
(
|
||||
baseFieldName,
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
// Determine number of processor actually having this field
|
||||
label fieldFound = (fieldHeader.headerOk() ? 1 : 0);
|
||||
reduce(fieldFound, sumOp<label>());
|
||||
|
||||
if (fieldFound == Pstream::nProcs())
|
||||
{
|
||||
if
|
||||
(
|
||||
fieldHeader.headerClassName()
|
||||
== volVectorField::typeName
|
||||
)
|
||||
{
|
||||
size_t cmptPos(fieldName.find_last_of("012"));
|
||||
|
||||
if (cmptPos == string::npos)
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "cannot find component index for "
|
||||
<< fieldName << exit(FatalError);
|
||||
}
|
||||
|
||||
direction cmpt =
|
||||
atoi(string(fieldName[cmptPos]).c_str());
|
||||
|
||||
Info<< "Sampling " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volVectorField vField(fieldHeader, mesh);
|
||||
|
||||
sampledScalarFields.set
|
||||
(
|
||||
nScalarFields,
|
||||
new volFieldSampler<scalar>
|
||||
(
|
||||
pInterpPtr(),
|
||||
interpolationSchemes,
|
||||
vField.component(cmpt)(),
|
||||
sampleSets
|
||||
)
|
||||
);
|
||||
|
||||
nScalarFields++;
|
||||
}
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerClassName()
|
||||
== volSymmTensorField::typeName
|
||||
)
|
||||
{
|
||||
size_t cmptPos(fieldName.find_last_of("0123456"));
|
||||
|
||||
if (cmptPos == string::npos)
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "cannot find component index for "
|
||||
<< fieldName
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
direction cmpt =
|
||||
atoi(string(fieldName[cmptPos]).c_str());
|
||||
|
||||
Info<< "Sampling " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volSymmTensorField tField(fieldHeader, mesh);
|
||||
|
||||
sampledScalarFields.set
|
||||
(
|
||||
nScalarFields,
|
||||
new volFieldSampler<scalar>
|
||||
(
|
||||
pInterpPtr(),
|
||||
interpolationSchemes,
|
||||
tField.component(cmpt)(),
|
||||
sampleSets
|
||||
)
|
||||
);
|
||||
|
||||
nScalarFields++;
|
||||
}
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerClassName()
|
||||
== volTensorField::typeName
|
||||
)
|
||||
{
|
||||
size_t cmptPos(fieldName.find_last_of("012345678"));
|
||||
|
||||
if (cmptPos == string::npos)
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "cannot find component index for "
|
||||
<< fieldName
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
direction cmpt =
|
||||
atoi(string(fieldName[cmptPos]).c_str());
|
||||
|
||||
Info<< "Sampling " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volTensorField tField(fieldHeader, mesh);
|
||||
|
||||
sampledScalarFields.set
|
||||
(
|
||||
nScalarFields,
|
||||
new volFieldSampler<scalar>
|
||||
(
|
||||
pInterpPtr(),
|
||||
interpolationSchemes,
|
||||
tField.component(cmpt)(),
|
||||
sampleSets
|
||||
)
|
||||
);
|
||||
|
||||
nScalarFields++;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "component function not supported for field "
|
||||
<< fieldName << " of type "
|
||||
<< fieldHeader.headerClassName()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
else if (fieldFound != 0)
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Did not find field " << baseFieldName
|
||||
<< " on all processors" << exit(FatalError);
|
||||
}
|
||||
|
||||
}
|
||||
else if (fieldName.find("mag") != string::npos)
|
||||
{
|
||||
string baseFieldName
|
||||
(
|
||||
fieldName(fieldName.find('(') + 1,
|
||||
fieldName.find(')') - fieldName.find('(') - 1)
|
||||
);
|
||||
|
||||
IOobject fieldHeader
|
||||
(
|
||||
baseFieldName,
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
// Determine number of processor actually having this field
|
||||
label fieldFound = (fieldHeader.headerOk() ? 1 : 0);
|
||||
reduce(fieldFound, sumOp<label>());
|
||||
|
||||
|
||||
if (fieldFound == Pstream::nProcs())
|
||||
{
|
||||
if
|
||||
(
|
||||
fieldHeader.headerClassName()
|
||||
== volScalarField::typeName
|
||||
)
|
||||
{
|
||||
Info<< "Sampling " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volScalarField sField(fieldHeader, mesh);
|
||||
|
||||
sampledScalarFields.set
|
||||
(
|
||||
nScalarFields,
|
||||
new volFieldSampler<scalar>
|
||||
(
|
||||
pInterpPtr(),
|
||||
interpolationSchemes,
|
||||
mag(sField),
|
||||
sampleSets
|
||||
)
|
||||
);
|
||||
|
||||
nScalarFields++;
|
||||
}
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerClassName()
|
||||
== volVectorField::typeName
|
||||
)
|
||||
{
|
||||
Info<< "Sampling " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volVectorField vField(fieldHeader, mesh);
|
||||
|
||||
sampledScalarFields.set
|
||||
(
|
||||
nScalarFields,
|
||||
new volFieldSampler<scalar>
|
||||
(
|
||||
pInterpPtr(),
|
||||
interpolationSchemes,
|
||||
mag(vField),
|
||||
sampleSets
|
||||
)
|
||||
);
|
||||
|
||||
nScalarFields++;
|
||||
}
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerClassName()
|
||||
== volSphericalTensorField::typeName
|
||||
)
|
||||
{
|
||||
Info<< "Sampling " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volSphericalTensorField tField(fieldHeader, mesh);
|
||||
|
||||
sampledScalarFields.set
|
||||
(
|
||||
nScalarFields,
|
||||
new volFieldSampler<scalar>
|
||||
(
|
||||
pInterpPtr(),
|
||||
interpolationSchemes,
|
||||
mag(tField),
|
||||
sampleSets
|
||||
)
|
||||
);
|
||||
|
||||
nScalarFields++;
|
||||
}
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerClassName()
|
||||
== volSymmTensorField::typeName
|
||||
)
|
||||
{
|
||||
Info<< "Sampling " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volSymmTensorField tField(fieldHeader, mesh);
|
||||
|
||||
sampledScalarFields.set
|
||||
(
|
||||
nScalarFields,
|
||||
new volFieldSampler<scalar>
|
||||
(
|
||||
pInterpPtr(),
|
||||
interpolationSchemes,
|
||||
mag(tField),
|
||||
sampleSets
|
||||
)
|
||||
);
|
||||
|
||||
nScalarFields++;
|
||||
}
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerClassName()
|
||||
== volTensorField::typeName
|
||||
)
|
||||
{
|
||||
Info<< "Sampling " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volTensorField tField(fieldHeader, mesh);
|
||||
|
||||
sampledScalarFields.set
|
||||
(
|
||||
nScalarFields,
|
||||
new volFieldSampler<scalar>
|
||||
(
|
||||
pInterpPtr(),
|
||||
interpolationSchemes,
|
||||
mag(tField),
|
||||
sampleSets
|
||||
)
|
||||
);
|
||||
|
||||
nScalarFields++;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "mag function not supported for field "
|
||||
<< fieldName << " of type "
|
||||
<< fieldHeader.headerClassName()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
else if (fieldFound != 0)
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Did not find field " << baseFieldName
|
||||
<< " on all processors" << exit(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the sampledFields to the correct size
|
||||
sampledScalarFields.setSize(nScalarFields);
|
||||
sampledVectorFields.setSize(nVectorFields);
|
||||
sampledSphericalTensorFields.setSize(nSphericalTensorFields);
|
||||
sampledSymmTensorFields.setSize(nSymmTensorFields);
|
||||
sampledTensorFields.setSize(nTensorFields);
|
||||
|
||||
//
|
||||
// Now we have all results
|
||||
// - sampleSets : list of all sampling sets
|
||||
// - sampledXXXFields : list of all sampled fields
|
||||
//
|
||||
|
||||
// Combine sampleSets from processors. Sort by curveDist. Return
|
||||
// ordering in indexSets.
|
||||
// Note: only master results are valid
|
||||
|
||||
PtrList<coordSet> masterSampleSets(sampleSets.size());
|
||||
labelListList indexSets(sampleSets.size());
|
||||
combineSampleSets(sampleSets, masterSampleSets, indexSets);
|
||||
|
||||
|
||||
// Combine sampled fields from processors.
|
||||
// Note: only master results are valid
|
||||
|
||||
PtrList<volFieldSampler<scalar> > masterScalarFields
|
||||
(
|
||||
sampledScalarFields.size()
|
||||
);
|
||||
combineSampleValues(sampledScalarFields, indexSets, masterScalarFields);
|
||||
|
||||
PtrList<volFieldSampler<vector> > masterVectorFields
|
||||
(
|
||||
sampledVectorFields.size()
|
||||
);
|
||||
combineSampleValues(sampledVectorFields, indexSets, masterVectorFields);
|
||||
|
||||
PtrList<volFieldSampler<sphericalTensor> > masterSphericalTensorFields
|
||||
(
|
||||
sampledSphericalTensorFields.size()
|
||||
);
|
||||
combineSampleValues
|
||||
(
|
||||
sampledSphericalTensorFields,
|
||||
indexSets,
|
||||
masterSphericalTensorFields
|
||||
);
|
||||
|
||||
PtrList<volFieldSampler<symmTensor> > masterSymmTensorFields
|
||||
(
|
||||
sampledSymmTensorFields.size()
|
||||
);
|
||||
combineSampleValues
|
||||
(
|
||||
sampledSymmTensorFields,
|
||||
indexSets,
|
||||
masterSymmTensorFields
|
||||
);
|
||||
|
||||
PtrList<volFieldSampler<tensor> > masterTensorFields
|
||||
(
|
||||
sampledTensorFields.size()
|
||||
);
|
||||
combineSampleValues(sampledTensorFields, indexSets, masterTensorFields);
|
||||
|
||||
|
||||
//
|
||||
// Write each set, each Field type (scalar/vector/tensor) to separate
|
||||
// file.
|
||||
//
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName timeDir(samplePath/runTime.timeName());
|
||||
|
||||
// Mirror the time structure under "samples"
|
||||
mkDir(timeDir);
|
||||
|
||||
forAll(masterSampleSets, setI)
|
||||
{
|
||||
writeSampleFile
|
||||
(
|
||||
masterSampleSets[setI],
|
||||
masterScalarFields,
|
||||
setI,
|
||||
timeDir,
|
||||
writeFormat
|
||||
);
|
||||
|
||||
writeSampleFile
|
||||
(
|
||||
masterSampleSets[setI],
|
||||
masterVectorFields,
|
||||
setI,
|
||||
timeDir,
|
||||
writeFormat
|
||||
);
|
||||
|
||||
writeSampleFile
|
||||
(
|
||||
masterSampleSets[setI],
|
||||
masterSphericalTensorFields,
|
||||
setI,
|
||||
timeDir,
|
||||
writeFormat
|
||||
);
|
||||
|
||||
writeSampleFile
|
||||
(
|
||||
masterSampleSets[setI],
|
||||
masterSymmTensorFields,
|
||||
setI,
|
||||
timeDir,
|
||||
writeFormat
|
||||
);
|
||||
|
||||
writeSampleFile
|
||||
(
|
||||
masterSampleSets[setI],
|
||||
masterTensorFields,
|
||||
setI,
|
||||
timeDir,
|
||||
writeFormat
|
||||
);
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,119 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
|
||||
root "/home/penfold/mattijs/foam/mattijs2.1/run/icoFoam";
|
||||
case "cavity";
|
||||
instance "system";
|
||||
local "";
|
||||
|
||||
class dictionary;
|
||||
object sampleDict;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// interpolationScheme : choice of
|
||||
// cell : use cell-centre value only; constant over cells
|
||||
// cellPoint : use cell-centre and vertex values
|
||||
// cellPointFace : use cell-centre, vertex and face values.
|
||||
// 1] vertex values determined from neighbouring cell-centre values
|
||||
// 2] face values determined using the current face interpolation scheme
|
||||
// for the field (linear, gamma, etc.)
|
||||
interpolationScheme cellPoint;
|
||||
|
||||
|
||||
// writeFormat : choice of
|
||||
// xmgr
|
||||
// jplot
|
||||
// gnuplot
|
||||
// raw
|
||||
writeFormat raw;
|
||||
|
||||
|
||||
// sampling definition:
|
||||
//
|
||||
// Dictionary with fields
|
||||
// type : type of sampling method
|
||||
// name : name of samples. Used e.g. as filename
|
||||
// axis : how to write point coordinate
|
||||
// ... : depending on method
|
||||
//
|
||||
//
|
||||
// sample: choice of
|
||||
// uniform evenly distributed points on line
|
||||
// face one point per face intersection
|
||||
// midPoint one point per cell, inbetween two face intersections
|
||||
// midPointAndFace combination of face and midPoint
|
||||
//
|
||||
// curve specified points, not nessecary on line, uses
|
||||
// tracking
|
||||
// cloud specified points, uses findCell
|
||||
//
|
||||
//
|
||||
// axis: how to write point coordinate. Choice of
|
||||
// - x/y/z: x/y/z coordinate only
|
||||
// - xyz: three columns
|
||||
// (probably does not make sense for anything but raw)
|
||||
// - distance: distance from start of sampling line (if uses line) or
|
||||
// distance from first specified sampling point
|
||||
//
|
||||
// type specific:
|
||||
// uniform, face, midPoint, midPointAndFace : start and end coordinate
|
||||
// uniform: extra number of sampling points
|
||||
// curve, cloud: list of coordinates
|
||||
sampleSets
|
||||
(
|
||||
uniform
|
||||
{
|
||||
name lineX1;
|
||||
axis distance;
|
||||
|
||||
//- cavity
|
||||
start (0.02 0.051 0.005);
|
||||
end (0.06 0.051 0.005);
|
||||
nPoints 10;
|
||||
}
|
||||
|
||||
face
|
||||
{
|
||||
name lineX2;
|
||||
axis x;
|
||||
|
||||
//- flangeHex
|
||||
//start (0 20 -20);
|
||||
//end (0 20 10);
|
||||
|
||||
//- nablaCavity
|
||||
//start (-1 0.05 0.005);
|
||||
//end ( 1 0.05 0.005);
|
||||
|
||||
//- cavity
|
||||
start (0.0 0.51 0.005);
|
||||
end (2 0.51 0.005);
|
||||
nPoints 10;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// Fields to sample.
|
||||
fields
|
||||
(
|
||||
p
|
||||
mag(U)
|
||||
U.component(1)
|
||||
R.component(0)
|
||||
);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,177 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "cloudSet.H"
|
||||
#include "sampleSet.H"
|
||||
#include "meshSearch.H"
|
||||
#include "DynamicList.H"
|
||||
#include "polyMesh.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "word.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(cloudSet, 0);
|
||||
|
||||
addToRunTimeSelectionTable(sampleSet, cloudSet, word);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::cloudSet::calcSamples
|
||||
(
|
||||
DynamicList<point>& samplingPts,
|
||||
DynamicList<label>& samplingCells,
|
||||
DynamicList<label>& samplingFaces,
|
||||
DynamicList<label>& samplingSegments,
|
||||
DynamicList<scalar>& samplingCurveDist
|
||||
) const
|
||||
{
|
||||
forAll(sampleCoords_, sampleI)
|
||||
{
|
||||
label cellI = searchEngine().findCell(sampleCoords_[sampleI]);
|
||||
|
||||
if (cellI != -1)
|
||||
{
|
||||
samplingPts.append(sampleCoords_[sampleI]);
|
||||
samplingCells.append(cellI);
|
||||
samplingFaces.append(-1);
|
||||
samplingSegments.append(0);
|
||||
samplingCurveDist.append(1.0 * sampleI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::cloudSet::genSamples()
|
||||
{
|
||||
// Storage for sample points
|
||||
DynamicList<point> samplingPts;
|
||||
DynamicList<label> samplingCells;
|
||||
DynamicList<label> samplingFaces;
|
||||
DynamicList<label> samplingSegments;
|
||||
DynamicList<scalar> samplingCurveDist;
|
||||
|
||||
calcSamples
|
||||
(
|
||||
samplingPts,
|
||||
samplingCells,
|
||||
samplingFaces,
|
||||
samplingSegments,
|
||||
samplingCurveDist
|
||||
);
|
||||
|
||||
samplingPts.shrink();
|
||||
samplingCells.shrink();
|
||||
samplingFaces.shrink();
|
||||
samplingSegments.shrink();
|
||||
samplingCurveDist.shrink();
|
||||
|
||||
setSamples
|
||||
(
|
||||
samplingPts,
|
||||
samplingCells,
|
||||
samplingFaces,
|
||||
samplingSegments,
|
||||
samplingCurveDist
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::cloudSet::cloudSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const List<point>& sampleCoords
|
||||
)
|
||||
:
|
||||
sampleSet(mesh, searchEngine, name, axis),
|
||||
sampleCoords_(sampleCoords)
|
||||
{
|
||||
genSamples();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
write(Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Construct from dictionary
|
||||
Foam::cloudSet::cloudSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
sampleSet(mesh, searchEngine, dict),
|
||||
sampleCoords_(dict.lookup("points"))
|
||||
{
|
||||
genSamples();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
write(Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cloudSet::~cloudSet()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::point Foam::cloudSet::getRefPoint(const List<point>& pts) const
|
||||
{
|
||||
if (pts.size() > 0)
|
||||
{
|
||||
// Use first samplePt as starting point
|
||||
return pts[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return vector::zero;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,126 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::cloudSet
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
cloudSet.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef cloudSet_H
|
||||
#define cloudSet_H
|
||||
|
||||
#include "sampleSet.H"
|
||||
#include "DynamicList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class passiveParticle;
|
||||
template<class Type> class particle;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cloudSet Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class cloudSet
|
||||
:
|
||||
public sampleSet
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Sampling points
|
||||
List<point> sampleCoords_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Samples all points in sampleCoords.
|
||||
void calcSamples
|
||||
(
|
||||
DynamicList<point>& samplingPts,
|
||||
DynamicList<label>& samplingCells,
|
||||
DynamicList<label>& samplingFaces,
|
||||
DynamicList<label>& samplingSegments,
|
||||
DynamicList<scalar>& samplingCurveDist
|
||||
) const;
|
||||
|
||||
//- Uses calcSamples to obtain samples. Copies them into *this.
|
||||
void genSamples();
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("cloud");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
cloudSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const List<point>& sampleCoords
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
cloudSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~cloudSet();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Get reference point
|
||||
virtual point getRefPoint(const List<point>&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,174 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "coordSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
//- Construct from components
|
||||
Foam::coordSet::coordSet
|
||||
(
|
||||
const word& name,
|
||||
const word& axis
|
||||
)
|
||||
:
|
||||
pointField(0),
|
||||
name_(name),
|
||||
axis_(axis),
|
||||
refPoint_(vector::zero)
|
||||
{}
|
||||
|
||||
|
||||
//- Construct from components
|
||||
Foam::coordSet::coordSet
|
||||
(
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const List<point>& points,
|
||||
const point& refPoint
|
||||
)
|
||||
:
|
||||
pointField(points),
|
||||
name_(name),
|
||||
axis_(axis),
|
||||
refPoint_(refPoint)
|
||||
{}
|
||||
|
||||
|
||||
//- Construct from components
|
||||
Foam::coordSet::coordSet
|
||||
(
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const scalarField& points,
|
||||
const scalar refPoint
|
||||
)
|
||||
:
|
||||
pointField(points.size(), point::zero),
|
||||
name_(name),
|
||||
axis_(axis),
|
||||
refPoint_(point::zero)
|
||||
{
|
||||
if (axis_ == "x" || axis_ == "distance")
|
||||
{
|
||||
refPoint_.x() = refPoint;
|
||||
replace(point::X, points);
|
||||
}
|
||||
else if (axis_ == "y")
|
||||
{
|
||||
replace(point::Y, points);
|
||||
}
|
||||
else if (axis_ == "z")
|
||||
{
|
||||
replace(point::Z, points);
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"coordSet::coordSet(const word& name,"
|
||||
"const word& axis, const List<scalar>& points,"
|
||||
"const scalar refPoint)"
|
||||
) << "Illegal axis specification " << axis_
|
||||
<< " for sampling line " << name_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::coordSet::hasVectorAxis() const
|
||||
{
|
||||
return axis_ == "xyz";
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::coordSet::scalarCoord
|
||||
(
|
||||
const label index
|
||||
) const
|
||||
{
|
||||
const point& p = operator[](index);
|
||||
|
||||
if (axis_ == "x")
|
||||
{
|
||||
return p.x();
|
||||
}
|
||||
else if (axis_ == "y")
|
||||
{
|
||||
return p.y();
|
||||
}
|
||||
else if (axis_ == "z")
|
||||
{
|
||||
return p.z();
|
||||
}
|
||||
else if (axis_ == "distance")
|
||||
{
|
||||
// Use distance to reference point
|
||||
return mag(p - refPoint_);
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"coordSet::scalarCoord(const label)"
|
||||
) << "Illegal axis specification " << axis_
|
||||
<< " for sampling line " << name_
|
||||
<< exit(FatalError);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::point Foam::coordSet::vectorCoord(const label index) const
|
||||
{
|
||||
const point& p = operator[](index);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::coordSet::write(Ostream& os) const
|
||||
{
|
||||
os << "name:" << name_ << " axis:" << axis_ << " reference:" << refPoint_
|
||||
<< endl
|
||||
<< endl << "\t(coord)"
|
||||
<< endl;
|
||||
|
||||
forAll(*this, sampleI)
|
||||
{
|
||||
os << '\t' << operator[](sampleI) << endl;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,145 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::coordSet
|
||||
|
||||
Description
|
||||
Holds list of sampling positions
|
||||
|
||||
SourceFiles
|
||||
coordSet.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef coordSet_H
|
||||
#define coordSet_H
|
||||
|
||||
#include "pointField.H"
|
||||
#include "word.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class coordSet Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class coordSet
|
||||
:
|
||||
public pointField
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
//- Name
|
||||
const word name_;
|
||||
|
||||
//- Axis write type
|
||||
const word axis_;
|
||||
|
||||
//- Reference point for "distance" write specifier.
|
||||
point refPoint_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
coordSet
|
||||
(
|
||||
const word& name,
|
||||
const word& axis
|
||||
);
|
||||
|
||||
|
||||
//- Construct from components
|
||||
coordSet
|
||||
(
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const List<point>& points,
|
||||
const point& refPoint = point::zero
|
||||
);
|
||||
|
||||
//- Construct from components
|
||||
coordSet
|
||||
(
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const scalarField& points,
|
||||
const scalar refPoint = 0.0
|
||||
);
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
const word& axis() const
|
||||
{
|
||||
return axis_;
|
||||
}
|
||||
|
||||
const point& refPoint() const
|
||||
{
|
||||
return refPoint_;
|
||||
}
|
||||
|
||||
//- Is axis specification a vector
|
||||
bool hasVectorAxis() const;
|
||||
|
||||
//- Get coordinate of point according to axis specification.
|
||||
// If axis="distance" can be: -distance to starting point (e.g.
|
||||
// uniformSet) or -distance to first sampling point
|
||||
// (e.g. cloudSet)
|
||||
scalar scalarCoord
|
||||
(
|
||||
const label index
|
||||
) const;
|
||||
|
||||
//- Get point according to axis="full" specification
|
||||
vector vectorCoord
|
||||
(
|
||||
const label index
|
||||
) const;
|
||||
|
||||
Ostream& write(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,421 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "curveSet.H"
|
||||
#include "meshSearch.H"
|
||||
#include "DynamicList.H"
|
||||
#include "polyMesh.H"
|
||||
|
||||
#include "Cloud.H"
|
||||
#include "passiveParticle.H"
|
||||
#include "IDLList.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(curveSet, 0);
|
||||
|
||||
addToRunTimeSelectionTable(sampleSet, curveSet, word);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// Sample till hits boundary.
|
||||
bool Foam::curveSet::trackToBoundary
|
||||
(
|
||||
Particle<passiveParticle>& singleParticle,
|
||||
label& sampleI,
|
||||
DynamicList<point>& samplingPts,
|
||||
DynamicList<label>& samplingCells,
|
||||
DynamicList<label>& samplingFaces,
|
||||
DynamicList<scalar>& samplingCurveDist
|
||||
) const
|
||||
{
|
||||
// Alias
|
||||
const point& trackPt = singleParticle.position();
|
||||
|
||||
while(true)
|
||||
{
|
||||
// Local geometry info
|
||||
const vector offset = sampleCoords_[sampleI+1] - sampleCoords_[sampleI];
|
||||
const scalar smallDist = mag(tol*offset);
|
||||
|
||||
point oldPos = trackPt;
|
||||
label facei = -1;
|
||||
do
|
||||
{
|
||||
singleParticle.stepFraction() = 0;
|
||||
singleParticle.track(sampleCoords_[sampleI+1]);
|
||||
}
|
||||
while
|
||||
(
|
||||
!singleParticle.onBoundary()
|
||||
&& (mag(trackPt - oldPos) < smallDist)
|
||||
);
|
||||
|
||||
if (singleParticle.onBoundary())
|
||||
{
|
||||
//Info<< "trackToBoundary : reached boundary"
|
||||
// << " trackPt:" << trackPt << endl;
|
||||
if
|
||||
(
|
||||
mag(trackPt - sampleCoords_[sampleI+1])
|
||||
< smallDist
|
||||
)
|
||||
{
|
||||
// Reached samplePt on boundary
|
||||
//Info<< "trackToBoundary : boundary. also sampling."
|
||||
// << " trackPt:" << trackPt << " sampleI+1:" << sampleI+1
|
||||
// << endl;
|
||||
samplingPts.append(trackPt);
|
||||
samplingCells.append(singleParticle.cell());
|
||||
samplingFaces.append(facei);
|
||||
|
||||
// trackPt is at sampleI+1
|
||||
samplingCurveDist.append(1.0*(sampleI+1));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Reached samplePt in cell
|
||||
samplingPts.append(trackPt);
|
||||
samplingCells.append(singleParticle.cell());
|
||||
samplingFaces.append(-1);
|
||||
|
||||
// Convert trackPt to fraction inbetween sampleI and sampleI+1
|
||||
scalar dist =
|
||||
mag(trackPt - sampleCoords_[sampleI])
|
||||
/ mag(sampleCoords_[sampleI+1] - sampleCoords_[sampleI]);
|
||||
samplingCurveDist.append(sampleI + dist);
|
||||
|
||||
// go to next samplePt
|
||||
sampleI++;
|
||||
|
||||
if (sampleI == sampleCoords_.size() - 1)
|
||||
{
|
||||
// no more samples.
|
||||
//Info<< "trackToBoundary : Reached end : sampleI now:" << sampleI
|
||||
// << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::curveSet::calcSamples
|
||||
(
|
||||
DynamicList<point>& samplingPts,
|
||||
DynamicList<label>& samplingCells,
|
||||
DynamicList<label>& samplingFaces,
|
||||
DynamicList<label>& samplingSegments,
|
||||
DynamicList<scalar>& samplingCurveDist
|
||||
) const
|
||||
{
|
||||
// Check sampling points
|
||||
if (sampleCoords_.size() < 2)
|
||||
{
|
||||
FatalErrorIn("curveSet::calcSamples()")
|
||||
<< "Incorrect sample specification. Too few points:"
|
||||
<< sampleCoords_ << exit(FatalError);
|
||||
}
|
||||
point oldPoint = sampleCoords_[0];
|
||||
for(label sampleI = 1; sampleI < sampleCoords_.size(); sampleI++)
|
||||
{
|
||||
if (mag(sampleCoords_[sampleI] - oldPoint) < SMALL)
|
||||
{
|
||||
FatalErrorIn("curveSet::calcSamples()")
|
||||
<< "Incorrect sample specification."
|
||||
<< " Point " << sampleCoords_[sampleI-1]
|
||||
<< " at position " << sampleI-1
|
||||
<< " and point " << sampleCoords_[sampleI]
|
||||
<< " at position " << sampleI
|
||||
<< " are too close" << exit(FatalError);
|
||||
}
|
||||
oldPoint = sampleCoords_[sampleI];
|
||||
}
|
||||
|
||||
// current segment number
|
||||
label segmentI = 0;
|
||||
|
||||
// starting index of current segment in samplePts
|
||||
label startSegmentI = 0;
|
||||
|
||||
label sampleI = 0;
|
||||
|
||||
point lastSample(GREAT, GREAT, GREAT);
|
||||
while(true)
|
||||
{
|
||||
// Get boundary intersection
|
||||
point trackPt;
|
||||
label trackCellI = -1;
|
||||
label trackFaceI = -1;
|
||||
|
||||
do
|
||||
{
|
||||
const vector offset =
|
||||
sampleCoords_[sampleI+1] - sampleCoords_[sampleI];
|
||||
const scalar smallDist = mag(tol*offset);
|
||||
|
||||
|
||||
// Get all boundary intersections
|
||||
List<pointIndexHit> bHits =
|
||||
searchEngine().intersections
|
||||
(
|
||||
sampleCoords_[sampleI],
|
||||
sampleCoords_[sampleI+1]
|
||||
);
|
||||
|
||||
point bPoint(GREAT, GREAT, GREAT);
|
||||
label bFaceI = -1;
|
||||
|
||||
if (bHits.size() > 0)
|
||||
{
|
||||
bPoint = bHits[0].hitPoint();
|
||||
bFaceI = bHits[0].index();
|
||||
}
|
||||
|
||||
// Get tracking point
|
||||
|
||||
bool isSample =
|
||||
getTrackingPoint
|
||||
(
|
||||
sampleCoords_[sampleI+1] - sampleCoords_[sampleI],
|
||||
sampleCoords_[sampleI],
|
||||
bPoint,
|
||||
bFaceI,
|
||||
|
||||
trackPt,
|
||||
trackCellI,
|
||||
trackFaceI
|
||||
);
|
||||
|
||||
if (isSample && (mag(lastSample - trackPt) > smallDist))
|
||||
{
|
||||
//Info<< "calcSamples : getTrackingPoint returned valid sample "
|
||||
// << " trackPt:" << trackPt
|
||||
// << " trackFaceI:" << trackFaceI
|
||||
// << " trackCellI:" << trackCellI
|
||||
// << " sampleI:" << sampleI
|
||||
// << " dist:" << dist
|
||||
// << endl;
|
||||
|
||||
samplingPts.append(trackPt);
|
||||
samplingCells.append(trackCellI);
|
||||
samplingFaces.append(trackFaceI);
|
||||
|
||||
// Convert sampling position to unique curve parameter. Get
|
||||
// fraction of distance between sampleI and sampleI+1.
|
||||
scalar dist =
|
||||
mag(trackPt - sampleCoords_[sampleI])
|
||||
/ mag(sampleCoords_[sampleI+1] - sampleCoords_[sampleI]);
|
||||
samplingCurveDist.append(sampleI + dist);
|
||||
|
||||
lastSample = trackPt;
|
||||
}
|
||||
|
||||
if (trackCellI == -1)
|
||||
{
|
||||
// No intersection found. Go to next point
|
||||
sampleI++;
|
||||
}
|
||||
} while((trackCellI == -1) && (sampleI < sampleCoords_.size() - 1));
|
||||
|
||||
if (sampleI == sampleCoords_.size() - 1)
|
||||
{
|
||||
//Info<< "calcSamples : Reached end of samples: "
|
||||
// << " sampleI now:" << sampleI
|
||||
// << endl;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Segment sampleI .. sampleI+1 intersected by domain
|
||||
//
|
||||
|
||||
// Initialize tracking starting from sampleI
|
||||
Cloud<passiveParticle> particles(mesh(), IDLList<passiveParticle>());
|
||||
|
||||
passiveParticle singleParticle
|
||||
(
|
||||
particles,
|
||||
trackPt,
|
||||
trackCellI
|
||||
);
|
||||
|
||||
bool bReached = trackToBoundary
|
||||
(
|
||||
singleParticle,
|
||||
sampleI,
|
||||
samplingPts,
|
||||
samplingCells,
|
||||
samplingFaces,
|
||||
samplingCurveDist
|
||||
);
|
||||
|
||||
// fill sampleSegments
|
||||
for(label i = samplingPts.size() - 1; i >= startSegmentI; --i)
|
||||
{
|
||||
samplingSegments.append(segmentI);
|
||||
}
|
||||
|
||||
if (!bReached)
|
||||
{
|
||||
//Info<< "calcSamples : Reached end of samples: "
|
||||
// << " sampleI now:" << sampleI
|
||||
// << endl;
|
||||
break;
|
||||
}
|
||||
lastSample = singleParticle.position();
|
||||
|
||||
|
||||
// Find next boundary.
|
||||
sampleI++;
|
||||
|
||||
if (sampleI == sampleCoords_.size() - 1)
|
||||
{
|
||||
//Info<< "calcSamples : Reached end of samples: "
|
||||
// << " sampleI now:" << sampleI
|
||||
// << endl;
|
||||
break;
|
||||
}
|
||||
|
||||
segmentI++;
|
||||
|
||||
startSegmentI = samplingPts.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::curveSet::genSamples()
|
||||
{
|
||||
// Storage for sample points
|
||||
DynamicList<point> samplingPts;
|
||||
DynamicList<label> samplingCells;
|
||||
DynamicList<label> samplingFaces;
|
||||
DynamicList<label> samplingSegments;
|
||||
DynamicList<scalar> samplingCurveDist;
|
||||
|
||||
calcSamples
|
||||
(
|
||||
samplingPts,
|
||||
samplingCells,
|
||||
samplingFaces,
|
||||
samplingSegments,
|
||||
samplingCurveDist
|
||||
);
|
||||
|
||||
samplingPts.shrink();
|
||||
samplingCells.shrink();
|
||||
samplingFaces.shrink();
|
||||
samplingSegments.shrink();
|
||||
samplingCurveDist.shrink();
|
||||
|
||||
setSamples
|
||||
(
|
||||
samplingPts,
|
||||
samplingCells,
|
||||
samplingFaces,
|
||||
samplingSegments,
|
||||
samplingCurveDist
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::curveSet::curveSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const List<point>& sampleCoords
|
||||
)
|
||||
:
|
||||
sampleSet(mesh, searchEngine, name, axis),
|
||||
sampleCoords_(sampleCoords)
|
||||
{
|
||||
genSamples();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
write(Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Construct from dictionary
|
||||
Foam::curveSet::curveSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
sampleSet(mesh, searchEngine, dict),
|
||||
sampleCoords_(dict.lookup("points"))
|
||||
{
|
||||
genSamples();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
write(Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::curveSet::~curveSet()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::point Foam::curveSet::getRefPoint(const List<point>& pts) const
|
||||
{
|
||||
if (pts.size() > 0)
|
||||
{
|
||||
// Use first samplePt as starting point
|
||||
return pts[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return vector::zero;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,139 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::curveSet
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
curveSet.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef curveSet_H
|
||||
#define curveSet_H
|
||||
|
||||
#include "sampleSet.H"
|
||||
#include "DynamicList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class passiveParticle;
|
||||
template<class Type> class Particle;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class curveSet Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class curveSet
|
||||
:
|
||||
public sampleSet
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- sampling points
|
||||
List<point> sampleCoords_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Sample till hits boundary. Called with singleParticle at position
|
||||
// inbetween sampleCoords_[sampleI] and sampleCoords_[sampleI+1].
|
||||
// Returns false if end of samples reached.
|
||||
bool trackToBoundary
|
||||
(
|
||||
Particle<passiveParticle>& singleParticle,
|
||||
label& sampleI,
|
||||
DynamicList<point>& samplingPts,
|
||||
DynamicList<label>& samplingCells,
|
||||
DynamicList<label>& samplingFaces,
|
||||
DynamicList<scalar>& samplingCurveDist
|
||||
) const;
|
||||
|
||||
//- Samples all point in sampleCoords_
|
||||
// samplingSegments contains segmentNo for each sample.
|
||||
void calcSamples
|
||||
(
|
||||
DynamicList<point>& samplingPts,
|
||||
DynamicList<label>& samplingCells,
|
||||
DynamicList<label>& samplingFaces,
|
||||
DynamicList<label>& samplingSegments,
|
||||
DynamicList<scalar>& samplingCurveDist
|
||||
) const;
|
||||
|
||||
//- Uses calcSamples to obtain samples. Copies them into *this.
|
||||
void genSamples();
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("curve");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
curveSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const List<point>& samplePoints
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
curveSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~curveSet();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Get reference point
|
||||
virtual point getRefPoint(const List<point>&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,396 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "faceOnlySet.H"
|
||||
#include "meshSearch.H"
|
||||
#include "DynamicList.H"
|
||||
#include "polyMesh.H"
|
||||
|
||||
#include "Cloud.H"
|
||||
#include "passiveParticle.H"
|
||||
#include "IDLList.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(faceOnlySet, 0);
|
||||
addToRunTimeSelectionTable(sampleSet, faceOnlySet, word);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// Sample singly connected segment. Returns false if end_ reached.
|
||||
bool Foam::faceOnlySet::trackToBoundary
|
||||
(
|
||||
Particle<passiveParticle>& singleParticle,
|
||||
DynamicList<point>& samplingPts,
|
||||
DynamicList<label>& samplingCells,
|
||||
DynamicList<label>& samplingFaces,
|
||||
DynamicList<scalar>& samplingCurveDist
|
||||
) const
|
||||
{
|
||||
// distance vector between sampling points
|
||||
const vector offset = end_ - start_;
|
||||
const vector smallVec = tol*offset;
|
||||
const scalar smallDist = mag(smallVec);
|
||||
|
||||
// Alias
|
||||
const point& trackPt = singleParticle.position();
|
||||
|
||||
while(true)
|
||||
{
|
||||
point oldPoint = trackPt;
|
||||
|
||||
singleParticle.trackToFace(end_);
|
||||
|
||||
if (singleParticle.face() != -1 && mag(oldPoint - trackPt) > smallDist)
|
||||
{
|
||||
// Reached face. Sample.
|
||||
samplingPts.append(trackPt);
|
||||
samplingCells.append(singleParticle.cell());
|
||||
samplingFaces.append(singleParticle.face());
|
||||
samplingCurveDist.append(mag(trackPt - start_));
|
||||
}
|
||||
|
||||
if (mag(trackPt - end_) < smallDist)
|
||||
{
|
||||
// end reached
|
||||
return false;
|
||||
}
|
||||
else if (singleParticle.onBoundary())
|
||||
{
|
||||
// Boundary reached.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::faceOnlySet::calcSamples
|
||||
(
|
||||
DynamicList<point>& samplingPts,
|
||||
DynamicList<label>& samplingCells,
|
||||
DynamicList<label>& samplingFaces,
|
||||
DynamicList<label>& samplingSegments,
|
||||
DynamicList<scalar>& samplingCurveDist
|
||||
) const
|
||||
{
|
||||
// distance vector between sampling points
|
||||
if (mag(end_ - start_) < SMALL)
|
||||
{
|
||||
FatalErrorIn("faceOnlySet::calcSamples()")
|
||||
<< "Incorrect sample specification :"
|
||||
<< " start equals end point." << endl
|
||||
<< " start:" << start_
|
||||
<< " end:" << end_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
const vector offset = (end_ - start_);
|
||||
const vector normOffset = offset/mag(offset);
|
||||
const vector smallVec = tol*offset;
|
||||
const scalar smallDist = mag(smallVec);
|
||||
|
||||
|
||||
// Get all boundary intersections
|
||||
List<pointIndexHit> bHits =
|
||||
searchEngine().intersections
|
||||
(
|
||||
start_ - smallVec,
|
||||
end_ + smallVec
|
||||
);
|
||||
|
||||
point bPoint(GREAT, GREAT, GREAT);
|
||||
label bFaceI = -1;
|
||||
|
||||
if (bHits.size() > 0)
|
||||
{
|
||||
bPoint = bHits[0].hitPoint();
|
||||
bFaceI = bHits[0].index();
|
||||
}
|
||||
|
||||
// Get first tracking point. Use bPoint, bFaceI if provided.
|
||||
|
||||
point trackPt;
|
||||
label trackCellI = -1;
|
||||
label trackFaceI = -1;
|
||||
|
||||
//Info<< "before getTrackingPoint : bPoint:" << bPoint
|
||||
// << " bFaceI:" << bFaceI << endl;
|
||||
|
||||
getTrackingPoint
|
||||
(
|
||||
offset,
|
||||
start_,
|
||||
bPoint,
|
||||
bFaceI,
|
||||
|
||||
trackPt,
|
||||
trackCellI,
|
||||
trackFaceI
|
||||
);
|
||||
|
||||
//Info<< "after getTrackingPoint : "
|
||||
// << " trackPt:" << trackPt
|
||||
// << " trackCellI:" << trackCellI
|
||||
// << " trackFaceI:" << trackFaceI
|
||||
// << endl;
|
||||
|
||||
if (trackCellI == -1)
|
||||
{
|
||||
// Line start_ - end_ does not intersect domain at all.
|
||||
// (or is along edge)
|
||||
// Set points and cell/face labels to empty lists
|
||||
//Info<< "calcSamples : Both start_ and end_ outside domain"
|
||||
// << endl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (trackFaceI == -1)
|
||||
{
|
||||
// No boundary face. Check for nearish internal face
|
||||
trackFaceI = findNearFace(trackCellI, trackPt, smallDist);
|
||||
}
|
||||
|
||||
//Info<< "calcSamples : got first point to track from :"
|
||||
// << " trackPt:" << trackPt
|
||||
// << " trackCell:" << trackCellI
|
||||
// << " trackFace:" << trackFaceI
|
||||
// << endl;
|
||||
|
||||
//
|
||||
// Track until hit end of all boundary intersections
|
||||
//
|
||||
|
||||
// current segment number
|
||||
label segmentI = 0;
|
||||
|
||||
// starting index of current segment in samplePts
|
||||
label startSegmentI = 0;
|
||||
|
||||
// index in bHits; current boundary intersection
|
||||
label bHitI = 1;
|
||||
|
||||
while(true)
|
||||
{
|
||||
if (trackFaceI != -1)
|
||||
{
|
||||
//Info<< "trackPt:" << trackPt << " on face so use." << endl;
|
||||
samplingPts.append(trackPt);
|
||||
samplingCells.append(trackCellI);
|
||||
samplingFaces.append(trackFaceI);
|
||||
samplingCurveDist.append(mag(trackPt - start_));
|
||||
}
|
||||
|
||||
// Initialize tracking starting from trackPt
|
||||
Cloud<passiveParticle> particles(mesh(), IDLList<passiveParticle>());
|
||||
|
||||
passiveParticle singleParticle
|
||||
(
|
||||
particles,
|
||||
trackPt,
|
||||
trackCellI
|
||||
);
|
||||
|
||||
bool reachedBoundary = trackToBoundary
|
||||
(
|
||||
singleParticle,
|
||||
samplingPts,
|
||||
samplingCells,
|
||||
samplingFaces,
|
||||
samplingCurveDist
|
||||
);
|
||||
|
||||
// fill sampleSegments
|
||||
for(label i = samplingPts.size() - 1; i >= startSegmentI; --i)
|
||||
{
|
||||
samplingSegments.append(segmentI);
|
||||
}
|
||||
|
||||
|
||||
if (!reachedBoundary)
|
||||
{
|
||||
//Info<< "calcSamples : Reached end of samples: "
|
||||
// << " samplePt now:" << singleParticle.position()
|
||||
// << endl;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Go past boundary intersection where tracking stopped
|
||||
// Use coordinate comparison instead of face comparison for
|
||||
// accuracy reasons
|
||||
|
||||
bool foundValidB = false;
|
||||
|
||||
while (bHitI < bHits.size())
|
||||
{
|
||||
scalar dist =
|
||||
(bHits[bHitI].hitPoint() - singleParticle.position())
|
||||
& normOffset;
|
||||
|
||||
//Info<< "Finding next boundary : "
|
||||
// << "bPoint:" << bHits[bHitI].hitPoint()
|
||||
// << " tracking:" << singleParticle.position()
|
||||
// << " dist:" << dist
|
||||
// << endl;
|
||||
|
||||
if (dist > smallDist)
|
||||
{
|
||||
// hitpoint is past tracking position
|
||||
foundValidB = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
bHitI++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundValidB)
|
||||
{
|
||||
// No valid boundary intersection found beyond tracking position
|
||||
break;
|
||||
}
|
||||
|
||||
// Update starting point for tracking
|
||||
trackFaceI = bHits[bHitI].index();
|
||||
trackPt = pushIn(bHits[bHitI].hitPoint(), trackFaceI);
|
||||
trackCellI = getBoundaryCell(trackFaceI);
|
||||
|
||||
segmentI++;
|
||||
|
||||
startSegmentI = samplingPts.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::faceOnlySet::genSamples()
|
||||
{
|
||||
// Storage for sample points
|
||||
DynamicList<point> samplingPts;
|
||||
DynamicList<label> samplingCells;
|
||||
DynamicList<label> samplingFaces;
|
||||
DynamicList<label> samplingSegments;
|
||||
DynamicList<scalar> samplingCurveDist;
|
||||
|
||||
calcSamples
|
||||
(
|
||||
samplingPts,
|
||||
samplingCells,
|
||||
samplingFaces,
|
||||
samplingSegments,
|
||||
samplingCurveDist
|
||||
);
|
||||
|
||||
samplingPts.shrink();
|
||||
samplingCells.shrink();
|
||||
samplingFaces.shrink();
|
||||
samplingSegments.shrink();
|
||||
samplingCurveDist.shrink();
|
||||
|
||||
// Copy into *this
|
||||
setSamples
|
||||
(
|
||||
samplingPts,
|
||||
samplingCells,
|
||||
samplingFaces,
|
||||
samplingSegments,
|
||||
samplingCurveDist
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::faceOnlySet::faceOnlySet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const point& start,
|
||||
const point& end
|
||||
)
|
||||
:
|
||||
sampleSet(mesh, searchEngine, name, axis),
|
||||
start_(start),
|
||||
end_(end)
|
||||
{
|
||||
genSamples();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
write(Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Construct from dictionary
|
||||
Foam::faceOnlySet::faceOnlySet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
sampleSet(mesh, searchEngine, dict),
|
||||
start_(dict.lookup("start")),
|
||||
end_(dict.lookup("end"))
|
||||
{
|
||||
genSamples();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
write(Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::faceOnlySet::~faceOnlySet()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::point Foam::faceOnlySet::getRefPoint(const List<point>& pts) const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,153 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::faceOnlySet
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
faceOnlySet.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef faceOnlySet_H
|
||||
#define faceOnlySet_H
|
||||
|
||||
#include "sampleSet.H"
|
||||
#include "DynamicList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class passiveParticle;
|
||||
template<class Type> class Particle;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class faceOnlySet Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class faceOnlySet
|
||||
:
|
||||
public sampleSet
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Starting point
|
||||
point start_;
|
||||
|
||||
//- End point
|
||||
point end_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Samples from startTrackPt/CellI. Updates particle/samplePt/sampleI
|
||||
// and puts
|
||||
// samples in the DynamicLists. Returns false if end of all samples
|
||||
// reached
|
||||
bool trackToBoundary
|
||||
(
|
||||
Particle<passiveParticle>& singleParticle,
|
||||
DynamicList<point>& samplingPts,
|
||||
DynamicList<label>& samplingCells,
|
||||
DynamicList<label>& samplingFaces,
|
||||
DynamicList<scalar>& samplingCurve
|
||||
) const;
|
||||
|
||||
//- Samples from start_ to end_. samplingSegments contains segmentNo
|
||||
// for each sample.
|
||||
void calcSamples
|
||||
(
|
||||
DynamicList<point>& samplingPts,
|
||||
DynamicList<label>& samplingCells,
|
||||
DynamicList<label>& samplingFaces,
|
||||
DynamicList<label>& samplingSegments,
|
||||
DynamicList<scalar>& samplingCurveDist
|
||||
) const;
|
||||
|
||||
//- Uses calcSamples to obtain samples. Copies them into *this.
|
||||
void genSamples();
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("face");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
faceOnlySet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const point& start,
|
||||
const point& end
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
faceOnlySet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~faceOnlySet();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
const point& start() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
const point& end() const
|
||||
{
|
||||
return end_;
|
||||
}
|
||||
|
||||
//- Get reference point
|
||||
virtual point getRefPoint(const List<point>&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,169 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "midPointSet.H"
|
||||
#include "DynamicList.H"
|
||||
#include "polyMesh.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(midPointSet, 0);
|
||||
|
||||
addToRunTimeSelectionTable(sampleSet, midPointSet, word);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// Rework faceOnlySet samples.
|
||||
// Take two consecutive samples
|
||||
void Foam::midPointSet::genSamples()
|
||||
{
|
||||
// Generate midpoints.
|
||||
|
||||
List<point> midPoints(2*size());
|
||||
labelList midCells(2*size());
|
||||
labelList midSegments(2*size());
|
||||
scalarList midCurveDist(2*size());
|
||||
|
||||
label midI = 0;
|
||||
|
||||
label sampleI = 0;
|
||||
|
||||
while(true)
|
||||
{
|
||||
// calculate midpoint between sampleI and sampleI+1 (if in same segment)
|
||||
while
|
||||
(
|
||||
(sampleI < size() - 1)
|
||||
&& (segments_[sampleI] == segments_[sampleI+1])
|
||||
)
|
||||
{
|
||||
midPoints[midI] =
|
||||
0.5*(operator[](sampleI) + operator[](sampleI+1));
|
||||
|
||||
label cell1 = getCell(faces_[sampleI], midPoints[midI]);
|
||||
label cell2 = getCell(faces_[sampleI+1], midPoints[midI]);
|
||||
|
||||
if (cell1 != cell2)
|
||||
{
|
||||
FatalErrorIn("midPointSet::genSamples()")
|
||||
<< " sampleI:" << sampleI
|
||||
<< " midI:" << midI
|
||||
<< " sampleI:" << sampleI
|
||||
<< " pts[sampleI]:" << operator[](sampleI)
|
||||
<< " face[sampleI]:" << faces_[sampleI]
|
||||
<< " pts[sampleI+1]:" << operator[](sampleI+1)
|
||||
<< " face[sampleI+1]:" << faces_[sampleI+1]
|
||||
<< " cell1:" << cell1
|
||||
<< " cell2:" << cell2
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
midCells[midI] = cell1;
|
||||
midSegments[midI] = segments_[sampleI];
|
||||
midCurveDist[midI] = mag(midPoints[midI] - start());
|
||||
|
||||
midI++;
|
||||
sampleI++;
|
||||
}
|
||||
|
||||
if (sampleI == size() - 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
sampleI++;
|
||||
}
|
||||
|
||||
midPoints.setSize(midI);
|
||||
midCells.setSize(midI);
|
||||
midSegments.setSize(midI);
|
||||
midCurveDist.setSize(midI);
|
||||
setSamples
|
||||
(
|
||||
midPoints,
|
||||
midCells,
|
||||
labelList(midCells.size(), -1),
|
||||
midSegments,
|
||||
midCurveDist
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::midPointSet::midPointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const point& start,
|
||||
const point& end
|
||||
)
|
||||
:
|
||||
faceOnlySet(mesh, searchEngine, name, axis, start, end)
|
||||
{
|
||||
genSamples();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
write(Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Construct from dictionary
|
||||
Foam::midPointSet::midPointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
faceOnlySet(mesh, searchEngine, dict)
|
||||
{
|
||||
genSamples();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
write(Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::midPointSet::~midPointSet()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,104 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::midPointSet
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
midPointSet.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef midPointSet_H
|
||||
#define midPointSet_H
|
||||
|
||||
#include "faceOnlySet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class passiveParticle;
|
||||
template<class Type> class particle;
|
||||
class meshSearch;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class midPointSet Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class midPointSet
|
||||
:
|
||||
public faceOnlySet
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
void genSamples();
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("midPoint");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
midPointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const point& start,
|
||||
const point& end
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
midPointSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~midPointSet();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,197 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "midPointAndFaceSet.H"
|
||||
#include "DynamicList.H"
|
||||
#include "polyMesh.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(midPointAndFaceSet, 0);
|
||||
|
||||
addToRunTimeSelectionTable(sampleSet, midPointAndFaceSet, word);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// Rework faceOnlySet samples.
|
||||
// Take two consecutive samples
|
||||
void Foam::midPointAndFaceSet::genSamples()
|
||||
{
|
||||
// Generate midpoints and add to face points
|
||||
|
||||
List<point> newSamplePoints(3*size());
|
||||
labelList newSampleCells(3*size());
|
||||
labelList newSampleFaces(3*size());
|
||||
labelList newSampleSegments(3*size());
|
||||
scalarList newSampleCurveDist(3*size());
|
||||
|
||||
label newSampleI = 0;
|
||||
|
||||
label sampleI = 0;
|
||||
|
||||
while(true)
|
||||
{
|
||||
// sampleI is start of segment
|
||||
|
||||
// Add sampleI
|
||||
newSamplePoints[newSampleI] = operator[](sampleI);
|
||||
newSampleCells[newSampleI] = cells_[sampleI];
|
||||
newSampleFaces[newSampleI] = faces_[sampleI];
|
||||
newSampleSegments[newSampleI] = segments_[sampleI];
|
||||
newSampleCurveDist[newSampleI] = curveDist_[sampleI];
|
||||
newSampleI++;
|
||||
|
||||
while
|
||||
(
|
||||
(sampleI < size() - 1)
|
||||
&& (segments_[sampleI] == segments_[sampleI+1])
|
||||
)
|
||||
{
|
||||
// Add mid point
|
||||
const point mid = 0.5*(operator[](sampleI) + operator[](sampleI+1));
|
||||
|
||||
label cell1 = getCell(faces_[sampleI], mid);
|
||||
label cell2 = getCell(faces_[sampleI+1], mid);
|
||||
|
||||
if (cell1 != cell2)
|
||||
{
|
||||
FatalErrorIn("midPointAndFaceSet::genSamples()")
|
||||
<< " sampleI:" << sampleI
|
||||
<< " newSampleI:" << newSampleI
|
||||
<< " pts[sampleI]:" << operator[](sampleI)
|
||||
<< " face[sampleI]:" << faces_[sampleI]
|
||||
<< " pts[sampleI+1]:" << operator[](sampleI+1)
|
||||
<< " face[sampleI+1]:" << faces_[sampleI+1]
|
||||
<< " cell1:" << cell1
|
||||
<< " cell2:" << cell2
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
newSamplePoints[newSampleI] = mid;
|
||||
newSampleCells[newSampleI] = cell1;
|
||||
newSampleFaces[newSampleI] = -1;
|
||||
newSampleSegments[newSampleI] = segments_[sampleI];
|
||||
newSampleCurveDist[newSampleI] =
|
||||
mag(newSamplePoints[newSampleI] - start());
|
||||
|
||||
newSampleI++;
|
||||
|
||||
// Add sampleI+1
|
||||
newSamplePoints[newSampleI] = operator[](sampleI+1);
|
||||
newSampleCells[newSampleI] = cells_[sampleI+1];
|
||||
newSampleFaces[newSampleI] = faces_[sampleI+1];
|
||||
newSampleSegments[newSampleI] = segments_[sampleI+1];
|
||||
newSampleCurveDist[newSampleI] =
|
||||
mag(newSamplePoints[newSampleI] - start());
|
||||
|
||||
newSampleI++;
|
||||
|
||||
sampleI++;
|
||||
}
|
||||
|
||||
if (sampleI == size() - 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
sampleI++;
|
||||
}
|
||||
|
||||
newSamplePoints.setSize(newSampleI);
|
||||
newSampleCells.setSize(newSampleI);
|
||||
newSampleFaces.setSize(newSampleI);
|
||||
newSampleSegments.setSize(newSampleI);
|
||||
newSampleCurveDist.setSize(newSampleI);
|
||||
|
||||
setSamples
|
||||
(
|
||||
newSamplePoints,
|
||||
newSampleCells,
|
||||
newSampleFaces,
|
||||
newSampleSegments,
|
||||
newSampleCurveDist
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::midPointAndFaceSet::midPointAndFaceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const point& start,
|
||||
const point& end
|
||||
)
|
||||
:
|
||||
faceOnlySet(mesh, searchEngine, name, axis, start, end)
|
||||
{
|
||||
genSamples();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
write(Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Construct from dictionary
|
||||
Foam::midPointAndFaceSet::midPointAndFaceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
faceOnlySet(mesh, searchEngine, dict)
|
||||
{
|
||||
genSamples();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
write(Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::midPointAndFaceSet::~midPointAndFaceSet()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,105 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::midPointAndFaceSet
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
midPointAndFaceSet.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef midPointAndFaceSet_H
|
||||
#define midPointAndFaceSet_H
|
||||
|
||||
#include "faceOnlySet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class passiveParticle;
|
||||
template<class Type> class particle;
|
||||
class meshSearch;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class midPointAndFaceSet Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class midPointAndFaceSet
|
||||
:
|
||||
public faceOnlySet
|
||||
{
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void genSamples();
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("midPointAndFace");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
midPointAndFaceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const point& start,
|
||||
const point& end
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
midPointAndFaceSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~midPointAndFaceSet();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,467 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "sampleSet.H"
|
||||
#include "polyMesh.H"
|
||||
#include "primitiveMesh.H"
|
||||
#include "meshSearch.H"
|
||||
#include "writer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
const scalar sampleSet::tol = 1e-6;
|
||||
|
||||
defineTypeNameAndDebug(sampleSet, 0);
|
||||
defineRunTimeSelectionTable(sampleSet, word);
|
||||
|
||||
autoPtr<sampleSet> sampleSet::New
|
||||
(
|
||||
const word& sampleType,
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
wordConstructorTable::iterator cstrIter =
|
||||
wordConstructorTablePtr_
|
||||
->find(sampleType);
|
||||
|
||||
if (cstrIter == wordConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"sampleSet::New(const word&, "
|
||||
"const polyMesh&, meshSearch&, const dictionary&)"
|
||||
) << "Unknown sample type " << sampleType
|
||||
<< endl << endl
|
||||
<< "Valid sample types : " << endl
|
||||
<< wordConstructorTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<sampleSet>
|
||||
(
|
||||
cstrIter()
|
||||
(
|
||||
mesh,
|
||||
searchEngine,
|
||||
dict
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::sampleSet::getBoundaryCell(const label faceI) const
|
||||
{
|
||||
return mesh().faceOwner()[faceI];
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::sampleSet::getCell
|
||||
(
|
||||
const label faceI,
|
||||
const point& sample
|
||||
) const
|
||||
{
|
||||
if (faceI == -1)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"sampleSet::getCell(const label, const point&)"
|
||||
) << "Illegal face label " << faceI
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
if (faceI >= mesh().nInternalFaces())
|
||||
{
|
||||
label cellI = getBoundaryCell(faceI);
|
||||
|
||||
if (!mesh().pointInCell(sample, cellI))
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"sampleSet::getCell(const label, const point&)"
|
||||
) << "Found cell " << cellI << " using face " << faceI
|
||||
<< ". But cell does not contain point " << sample
|
||||
<< abort(FatalError);
|
||||
}
|
||||
return cellI;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try owner and neighbour to see which one contains sample
|
||||
|
||||
label cellI = mesh().faceOwner()[faceI];
|
||||
|
||||
if (mesh().pointInCell(sample, cellI))
|
||||
{
|
||||
return cellI;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellI = mesh().faceNeighbour()[faceI];
|
||||
|
||||
if (mesh().pointInCell(sample, cellI))
|
||||
{
|
||||
return cellI;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"sampleSet::getCell(const label, const point&)"
|
||||
) << "None of the neighbours of face "
|
||||
<< faceI << " contains point " << sample
|
||||
<< abort(FatalError);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::sampleSet::calcSign
|
||||
(
|
||||
const label faceI,
|
||||
const point& sample
|
||||
) const
|
||||
{
|
||||
vector vec = sample - mesh().faceCentres()[faceI];
|
||||
|
||||
scalar magVec = mag(vec);
|
||||
|
||||
if (magVec < VSMALL)
|
||||
{
|
||||
// sample on face centre. Regard as inside
|
||||
return -1;
|
||||
}
|
||||
|
||||
vec /= magVec;
|
||||
|
||||
vector n = mesh().faceAreas()[faceI];
|
||||
|
||||
n /= mag(n) + VSMALL;
|
||||
|
||||
return n & vec;
|
||||
}
|
||||
|
||||
|
||||
// Return face (or -1) of face which is within smallDist of sample
|
||||
Foam::label Foam::sampleSet::findNearFace
|
||||
(
|
||||
const label cellI,
|
||||
const point& sample,
|
||||
const scalar smallDist
|
||||
) const
|
||||
{
|
||||
const cell& myFaces = mesh().cells()[cellI];
|
||||
|
||||
forAll(myFaces, myFaceI)
|
||||
{
|
||||
const face& f = mesh().faces()[myFaces[myFaceI]];
|
||||
|
||||
pointHit inter = f.nearestPoint(sample, mesh().points());
|
||||
|
||||
scalar dist;
|
||||
|
||||
if (inter.hit())
|
||||
{
|
||||
dist = mag(inter.hitPoint() - sample);
|
||||
}
|
||||
else
|
||||
{
|
||||
dist = mag(inter.missPoint() - sample);
|
||||
}
|
||||
|
||||
if (dist < smallDist)
|
||||
{
|
||||
return myFaces[myFaceI];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// 'Pushes' point facePt (which is almost on face) in direction of cell centre
|
||||
// so it is clearly inside.
|
||||
Foam::point Foam::sampleSet::pushIn
|
||||
(
|
||||
const point& facePt,
|
||||
const label faceI
|
||||
) const
|
||||
{
|
||||
label cellI = mesh().faceOwner()[faceI];
|
||||
|
||||
const point& cellCtr = mesh().cellCentres()[cellI];
|
||||
|
||||
point newSample =
|
||||
facePt + tol*(cellCtr - facePt);
|
||||
|
||||
if (!searchEngine().pointInCell(newSample, cellI))
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"sampleSet::pushIn(const point&, const label)"
|
||||
) << "After pushing " << facePt << " to " << newSample
|
||||
<< " it is still outside faceI " << faceI << endl
|
||||
<< "Please change your starting point"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
//Info<< "pushIn : moved " << facePt << " to " << newSample
|
||||
// << endl;
|
||||
|
||||
return newSample;
|
||||
}
|
||||
|
||||
|
||||
// Calculates start of tracking given samplePt and first boundary intersection
|
||||
// (bPoint, bFaceI). bFaceI == -1 if no boundary intersection.
|
||||
// Returns true if trackPt is sampling point
|
||||
bool Foam::sampleSet::getTrackingPoint
|
||||
(
|
||||
const vector& offset,
|
||||
const point& samplePt,
|
||||
const point& bPoint,
|
||||
const label bFaceI,
|
||||
|
||||
point& trackPt,
|
||||
label& trackCellI,
|
||||
label& trackFaceI
|
||||
) const
|
||||
{
|
||||
const scalar smallDist = mag(tol*offset);
|
||||
|
||||
bool isGoodSample = false;
|
||||
|
||||
if (bFaceI == -1)
|
||||
{
|
||||
// No boundary intersection. Try and find cell samplePt is in
|
||||
trackCellI = mesh().findCell(samplePt);
|
||||
|
||||
if
|
||||
(
|
||||
(trackCellI == -1)
|
||||
|| !mesh().pointInCell(samplePt, trackCellI)
|
||||
)
|
||||
{
|
||||
// Line samplePt - end_ does not intersect domain at all.
|
||||
// (or is along edge)
|
||||
//Info<< "getTrackingPoint : samplePt outside domain : "
|
||||
// << " samplePt:" << samplePt
|
||||
// << endl;
|
||||
|
||||
trackCellI = -1;
|
||||
trackFaceI = -1;
|
||||
|
||||
isGoodSample = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// start is inside. Use it as tracking point
|
||||
//Info<< "getTrackingPoint : samplePt inside :"
|
||||
// << " samplePt:" << samplePt
|
||||
// << " trackCellI:" << trackCellI
|
||||
// << endl;
|
||||
|
||||
trackPt = samplePt;
|
||||
trackFaceI = -1;
|
||||
|
||||
isGoodSample = true;
|
||||
}
|
||||
}
|
||||
else if (mag(samplePt - bPoint) < smallDist)
|
||||
{
|
||||
//Info<< "getTrackingPoint : samplePt:" << samplePt
|
||||
// << " close to bPoint:"
|
||||
// << bPoint << endl;
|
||||
|
||||
// samplePt close to bPoint. Snap to it
|
||||
trackPt = pushIn(bPoint, bFaceI);
|
||||
trackFaceI = bFaceI;
|
||||
trackCellI = getBoundaryCell(trackFaceI);
|
||||
|
||||
isGoodSample = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
scalar sign = calcSign(bFaceI, samplePt);
|
||||
|
||||
if (sign < 0)
|
||||
{
|
||||
// samplePt inside or marginally outside.
|
||||
trackPt = samplePt;
|
||||
trackFaceI = -1;
|
||||
trackCellI = mesh().findCell(trackPt);
|
||||
|
||||
isGoodSample = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// samplePt outside. use bPoint
|
||||
trackPt = pushIn(bPoint, bFaceI);
|
||||
trackFaceI = bFaceI;
|
||||
trackCellI = getBoundaryCell(trackFaceI);
|
||||
|
||||
isGoodSample = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "sampleSet::getTrackingPoint :"
|
||||
<< " offset:" << offset
|
||||
<< " samplePt:" << samplePt
|
||||
<< " bPoint:" << bPoint
|
||||
<< " bFaceI:" << bFaceI
|
||||
<< endl << " Calculated first tracking point :"
|
||||
<< " trackPt:" << trackPt
|
||||
<< " trackCellI:" << trackCellI
|
||||
<< " trackFaceI:" << trackFaceI
|
||||
<< " isGoodSample:" << isGoodSample
|
||||
<< endl;
|
||||
}
|
||||
|
||||
return isGoodSample;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampleSet::setSamples
|
||||
(
|
||||
const List<point>& samplingPts,
|
||||
const labelList& samplingCells,
|
||||
const labelList& samplingFaces,
|
||||
const labelList& samplingSegments,
|
||||
const scalarList& samplingCurveDist
|
||||
)
|
||||
{
|
||||
setSize(samplingPts.size());
|
||||
cells_.setSize(samplingCells.size());
|
||||
faces_.setSize(samplingFaces.size());
|
||||
segments_.setSize(samplingSegments.size());
|
||||
curveDist_.setSize(samplingCurveDist.size());
|
||||
|
||||
if
|
||||
(
|
||||
(cells_.size() != size())
|
||||
|| (faces_.size() != size())
|
||||
|| (segments_.size() != size())
|
||||
|| (curveDist_.size() != size())
|
||||
)
|
||||
{
|
||||
FatalErrorIn("sampleSet::setSamples()")
|
||||
<< "sizes not equal : "
|
||||
<< " points:" << size()
|
||||
<< " cells:" << cells_.size()
|
||||
<< " faces:" << faces_.size()
|
||||
<< " segments:" << segments_.size()
|
||||
<< " curveDist:" << curveDist_.size()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
forAll(samplingPts, sampleI)
|
||||
{
|
||||
operator[](sampleI) = samplingPts[sampleI];
|
||||
}
|
||||
cells_ = samplingCells;
|
||||
faces_ = samplingFaces;
|
||||
segments_ = samplingSegments;
|
||||
curveDist_ = samplingCurveDist;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from mesh, name
|
||||
Foam::sampleSet::sampleSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& axis
|
||||
)
|
||||
:
|
||||
coordSet(name, axis),
|
||||
mesh_(mesh),
|
||||
searchEngine_(searchEngine),
|
||||
segments_(0),
|
||||
curveDist_(0),
|
||||
cells_(0),
|
||||
faces_(0)
|
||||
{}
|
||||
|
||||
|
||||
// Construct from dictionary
|
||||
Foam::sampleSet::sampleSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
coordSet(dict.lookup("name"), dict.lookup("axis")),
|
||||
mesh_(mesh),
|
||||
searchEngine_(searchEngine),
|
||||
segments_(0),
|
||||
curveDist_(0),
|
||||
cells_(0),
|
||||
faces_(0)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sampleSet::~sampleSet()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::sampleSet::write(Ostream& os) const
|
||||
{
|
||||
coordSet::write(os);
|
||||
|
||||
os << endl << "\t(cellI)\t(faceI)"
|
||||
<< endl;
|
||||
forAll(*this, sampleI)
|
||||
{
|
||||
os << '\t' << cells_[sampleI]
|
||||
<< '\t' << faces_[sampleI]
|
||||
<< endl;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,296 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::sampleSet
|
||||
|
||||
Description
|
||||
Holds list of sampling points which is filled at construction time.
|
||||
Various implementations of this base class to e.g. get sampling points
|
||||
at uniform distance along a line (uniformSet) or directly specified
|
||||
(cloudSet)
|
||||
|
||||
Each 'sampleSet' has a name and a specifier of how the axis should be
|
||||
write (x/y/z component or all 3 components)
|
||||
|
||||
SourceFiles
|
||||
sampleSet.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef sampleSet_H
|
||||
#define sampleSet_H
|
||||
|
||||
#include "pointField.H"
|
||||
#include "word.H"
|
||||
#include "labelList.H"
|
||||
#include "typeInfo.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "autoPtr.H"
|
||||
#include "coordSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class polyMesh;
|
||||
class meshSearch;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sampleSet Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sampleSet
|
||||
:
|
||||
public coordSet
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference to mesh
|
||||
const polyMesh& mesh_;
|
||||
|
||||
//- Reference to mesh searching class
|
||||
meshSearch& searchEngine_;
|
||||
|
||||
protected:
|
||||
|
||||
//- Segment numbers
|
||||
labelList segments_;
|
||||
|
||||
//- Parameter along sample curve. Uniquely identifies position
|
||||
// along sampling. Used for combining parallel results.
|
||||
scalarList curveDist_;
|
||||
|
||||
//- Cell numbers
|
||||
labelList cells_;
|
||||
|
||||
//- Face numbers (-1 if not known)
|
||||
labelList faces_;
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Returns cell next to boundary face
|
||||
label getBoundaryCell(const label) const;
|
||||
|
||||
//- Returns cell using face and containing sample
|
||||
label getCell
|
||||
(
|
||||
const label faceI,
|
||||
const point& sample
|
||||
) const;
|
||||
|
||||
//- Calculates inproduct of face normal and vector sample-face centre
|
||||
// <0 if sample inside.
|
||||
scalar calcSign(const label faceI, const point& sample) const;
|
||||
|
||||
//- Returns face label (or -1) of face which is close to sample
|
||||
label findNearFace
|
||||
(
|
||||
const label cellI,
|
||||
const point& sample,
|
||||
const scalar smallDist
|
||||
) const;
|
||||
|
||||
//- Moves sample in direction of -n to it is 'inside' of faceI
|
||||
point pushIn
|
||||
(
|
||||
const point& sample,
|
||||
const label faceI
|
||||
) const;
|
||||
|
||||
//- Calculates start of tracking given samplePt and first boundary
|
||||
// intersection
|
||||
// (bPoint, bFaceI) (bFaceI == -1 if no boundary intersection)
|
||||
// Returns true if trackPt is valid sampling point. Sets trackPt,
|
||||
// trackFaceI, trackCellI (-1 if no tracking point found)
|
||||
bool getTrackingPoint
|
||||
(
|
||||
const vector& offset,
|
||||
const point& samplePt,
|
||||
const point& bPoint,
|
||||
const label bFaceI,
|
||||
|
||||
point& trackPt,
|
||||
label& trackCellI,
|
||||
label& trackFaceI
|
||||
) const;
|
||||
|
||||
//- Sets sample data
|
||||
void setSamples
|
||||
(
|
||||
const List<point>& samplingPts,
|
||||
const labelList& samplingCells,
|
||||
const labelList& samplingFaces,
|
||||
const labelList& samplingSegments,
|
||||
const scalarList& samplingCurveDist
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("sampleSet");
|
||||
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
sampleSet,
|
||||
word,
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
),
|
||||
(mesh, searchEngine, dict)
|
||||
);
|
||||
|
||||
|
||||
//- Class used for the read-construction of
|
||||
// PtrLists of sampleSet
|
||||
class iNew
|
||||
{
|
||||
const polyMesh& mesh_;
|
||||
meshSearch& searchEngine_;
|
||||
|
||||
public:
|
||||
|
||||
iNew(const polyMesh& mesh, meshSearch& searchEngine)
|
||||
:
|
||||
mesh_(mesh),
|
||||
searchEngine_(searchEngine)
|
||||
{}
|
||||
|
||||
autoPtr<sampleSet> operator()(Istream& is) const
|
||||
{
|
||||
word sampleType(is);
|
||||
dictionary dict(is);
|
||||
return sampleSet::New(sampleType, mesh_, searchEngine_, dict);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Static data
|
||||
|
||||
//- Tolerance when comparing points. Usually relative to difference
|
||||
// between start_ and end_
|
||||
const static scalar tol;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from mesh, name
|
||||
sampleSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& axis
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
sampleSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Clone
|
||||
autoPtr<sampleSet> clone() const
|
||||
{
|
||||
notImplemented("autoPtr<sampleSet> clone() const");
|
||||
return autoPtr<sampleSet>(NULL);
|
||||
}
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected sampleSet
|
||||
static autoPtr<sampleSet> New
|
||||
(
|
||||
const word& sampleType,
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~sampleSet();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
const polyMesh& mesh() const
|
||||
{
|
||||
return mesh_;
|
||||
}
|
||||
|
||||
meshSearch& searchEngine() const
|
||||
{
|
||||
return searchEngine_;
|
||||
}
|
||||
|
||||
const labelList& segments() const
|
||||
{
|
||||
return segments_;
|
||||
}
|
||||
|
||||
const scalarList& curveDist() const
|
||||
{
|
||||
return curveDist_;
|
||||
}
|
||||
|
||||
const labelList& cells() const
|
||||
{
|
||||
return cells_;
|
||||
}
|
||||
|
||||
const labelList& faces() const
|
||||
{
|
||||
return faces_;
|
||||
}
|
||||
|
||||
//- Given all sampling points (on all processors) return reference point
|
||||
virtual point getRefPoint(const List<point>&) const = 0;
|
||||
|
||||
//- Output for debugging
|
||||
Ostream& write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,499 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "uniformSet.H"
|
||||
#include "meshSearch.H"
|
||||
#include "DynamicList.H"
|
||||
#include "polyMesh.H"
|
||||
|
||||
#include "Cloud.H"
|
||||
#include "passiveParticle.H"
|
||||
#include "IDLList.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(uniformSet, 0);
|
||||
addToRunTimeSelectionTable(sampleSet, uniformSet, word);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// Finds along line (samplePt + t * offset) next sample beyond or equal to
|
||||
// currentPt.
|
||||
// Updates samplePt, sampleI
|
||||
bool Foam::uniformSet::nextSample
|
||||
(
|
||||
const point& currentPt,
|
||||
const vector& offset,
|
||||
const scalar smallDist,
|
||||
point& samplePt,
|
||||
label& sampleI
|
||||
) const
|
||||
{
|
||||
bool pointFound = false;
|
||||
|
||||
const vector normOffset = offset/mag(offset);
|
||||
|
||||
samplePt += offset;
|
||||
sampleI++;
|
||||
|
||||
for(; sampleI < nPoints_; sampleI++)
|
||||
{
|
||||
scalar s = (samplePt - currentPt) & normOffset;
|
||||
|
||||
if (s > -smallDist)
|
||||
{
|
||||
// samplePt is close to or beyond currentPt -> use it
|
||||
pointFound = true;
|
||||
|
||||
break;
|
||||
}
|
||||
samplePt += offset;
|
||||
}
|
||||
|
||||
return pointFound;
|
||||
}
|
||||
|
||||
|
||||
// Sample singly connected segment. Returns false if end_ reached.
|
||||
bool Foam::uniformSet::trackToBoundary
|
||||
(
|
||||
Particle<passiveParticle>& singleParticle,
|
||||
point& samplePt,
|
||||
label& sampleI,
|
||||
DynamicList<point>& samplingPts,
|
||||
DynamicList<label>& samplingCells,
|
||||
DynamicList<label>& samplingFaces,
|
||||
DynamicList<scalar>& samplingCurveDist
|
||||
) const
|
||||
{
|
||||
// distance vector between sampling points
|
||||
const vector offset = (end_ - start_)/(nPoints_ - 1);
|
||||
const vector smallVec = tol*offset;
|
||||
const scalar smallDist = mag(smallVec);
|
||||
|
||||
// Alias
|
||||
const point& trackPt = singleParticle.position();
|
||||
|
||||
while(true)
|
||||
{
|
||||
// Find next samplePt on/after trackPt. Update samplePt, sampleI
|
||||
if (!nextSample(trackPt, offset, smallDist, samplePt, sampleI))
|
||||
{
|
||||
// no more samples.
|
||||
if (debug)
|
||||
{
|
||||
Info<< "trackToBoundary : Reached end : samplePt now:"
|
||||
<< samplePt << " sampleI now:" << sampleI << endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mag(samplePt - trackPt) < smallDist)
|
||||
{
|
||||
// trackPt corresponds with samplePt. Store and use next samplePt
|
||||
if (debug)
|
||||
{
|
||||
Info<< "trackToBoundary : samplePt corresponds to trackPt : "
|
||||
<< " trackPt:" << trackPt << " samplePt:" << samplePt
|
||||
<< endl;
|
||||
}
|
||||
|
||||
samplingPts.append(trackPt);
|
||||
samplingCells.append(singleParticle.cell());
|
||||
samplingFaces.append(-1);
|
||||
samplingCurveDist.append(mag(trackPt - start_));
|
||||
|
||||
// go to next samplePt
|
||||
if (!nextSample(trackPt, offset, smallDist, samplePt, sampleI))
|
||||
{
|
||||
// no more samples.
|
||||
if (debug)
|
||||
{
|
||||
Info<< "trackToBoundary : Reached end : "
|
||||
<< " samplePt now:" << samplePt
|
||||
<< " sampleI now:" << sampleI
|
||||
<< endl;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Searching along trajectory from "
|
||||
<< " trackPt:" << trackPt
|
||||
<< " trackCellI:" << singleParticle.cell()
|
||||
<< " to:" << samplePt << endl;
|
||||
}
|
||||
|
||||
point oldPos = trackPt;
|
||||
label facei = -1;
|
||||
do
|
||||
{
|
||||
singleParticle.stepFraction() = 0;
|
||||
singleParticle.track(samplePt);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Result of tracking "
|
||||
<< " trackPt:" << trackPt
|
||||
<< " trackCellI:" << singleParticle.cell()
|
||||
<< " trackFaceI:" << singleParticle.face()
|
||||
<< " onBoundary:" << singleParticle.onBoundary()
|
||||
<< " samplePt:" << samplePt
|
||||
<< " smallDist:" << smallDist
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
while
|
||||
(
|
||||
!singleParticle.onBoundary()
|
||||
&& (mag(trackPt - oldPos) < smallDist)
|
||||
);
|
||||
|
||||
if (singleParticle.onBoundary())
|
||||
{
|
||||
//Info<< "trackToBoundary : reached boundary" << endl;
|
||||
if (mag(trackPt - samplePt) < smallDist)
|
||||
{
|
||||
//Info<< "trackToBoundary : boundary is also sampling point"
|
||||
// << endl;
|
||||
// Reached samplePt on boundary
|
||||
samplingPts.append(trackPt);
|
||||
samplingCells.append(singleParticle.cell());
|
||||
samplingFaces.append(facei);
|
||||
samplingCurveDist.append(mag(trackPt - start_));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//Info<< "trackToBoundary : reached internal sampling point" << endl;
|
||||
// Reached samplePt in cell or on internal face
|
||||
samplingPts.append(trackPt);
|
||||
samplingCells.append(singleParticle.cell());
|
||||
samplingFaces.append(-1);
|
||||
samplingCurveDist.append(mag(trackPt - start_));
|
||||
|
||||
// go to next samplePt
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::uniformSet::calcSamples
|
||||
(
|
||||
DynamicList<point>& samplingPts,
|
||||
DynamicList<label>& samplingCells,
|
||||
DynamicList<label>& samplingFaces,
|
||||
DynamicList<label>& samplingSegments,
|
||||
DynamicList<scalar>& samplingCurveDist
|
||||
) const
|
||||
{
|
||||
// distance vector between sampling points
|
||||
if ((nPoints_ < 2) || (mag(end_ - start_) < SMALL))
|
||||
{
|
||||
FatalErrorIn("uniformSet::calcSamples()")
|
||||
<< "Incorrect sample specification. Either too few points or"
|
||||
<< " start equals end point." << endl
|
||||
<< "nPoints:" << nPoints_
|
||||
<< " start:" << start_
|
||||
<< " end:" << end_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
const vector offset = (end_ - start_)/(nPoints_ - 1);
|
||||
const vector normOffset = offset/mag(offset);
|
||||
const vector smallVec = tol*offset;
|
||||
const scalar smallDist = mag(smallVec);
|
||||
|
||||
// Get all boundary intersections
|
||||
List<pointIndexHit> bHits =
|
||||
searchEngine().intersections
|
||||
(
|
||||
start_ - smallVec,
|
||||
end_ + smallVec
|
||||
);
|
||||
|
||||
point bPoint(GREAT, GREAT, GREAT);
|
||||
label bFaceI = -1;
|
||||
|
||||
if (bHits.size() > 0)
|
||||
{
|
||||
bPoint = bHits[0].hitPoint();
|
||||
bFaceI = bHits[0].index();
|
||||
}
|
||||
|
||||
// Get first tracking point. Use bPoint, bFaceI if provided.
|
||||
|
||||
point trackPt;
|
||||
label trackCellI = -1;
|
||||
label trackFaceI = -1;
|
||||
|
||||
bool isSample =
|
||||
getTrackingPoint
|
||||
(
|
||||
offset,
|
||||
start_,
|
||||
bPoint,
|
||||
bFaceI,
|
||||
|
||||
trackPt,
|
||||
trackCellI,
|
||||
trackFaceI
|
||||
);
|
||||
|
||||
if (trackCellI == -1)
|
||||
{
|
||||
// Line start_ - end_ does not intersect domain at all.
|
||||
// (or is along edge)
|
||||
// Set points and cell/face labels to empty lists
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (isSample)
|
||||
{
|
||||
samplingPts.append(start_);
|
||||
samplingCells.append(trackCellI);
|
||||
samplingFaces.append(trackFaceI);
|
||||
samplingCurveDist.append(0.0);
|
||||
}
|
||||
|
||||
//
|
||||
// Track until hit end of all boundary intersections
|
||||
//
|
||||
|
||||
// current segment number
|
||||
label segmentI = 0;
|
||||
|
||||
// starting index of current segment in samplePts
|
||||
label startSegmentI = 0;
|
||||
|
||||
label sampleI = 0;
|
||||
point samplePt = start_;
|
||||
|
||||
// index in bHits; current boundary intersection
|
||||
label bHitI = 1;
|
||||
|
||||
while(true)
|
||||
{
|
||||
// Initialize tracking starting from trackPt
|
||||
Cloud<passiveParticle> particles(mesh(), IDLList<passiveParticle>());
|
||||
|
||||
passiveParticle singleParticle
|
||||
(
|
||||
particles,
|
||||
trackPt,
|
||||
trackCellI
|
||||
);
|
||||
|
||||
bool reachedBoundary = trackToBoundary
|
||||
(
|
||||
singleParticle,
|
||||
samplePt,
|
||||
sampleI,
|
||||
samplingPts,
|
||||
samplingCells,
|
||||
samplingFaces,
|
||||
samplingCurveDist
|
||||
);
|
||||
|
||||
// fill sampleSegments
|
||||
for(label i = samplingPts.size() - 1; i >= startSegmentI; --i)
|
||||
{
|
||||
samplingSegments.append(segmentI);
|
||||
}
|
||||
|
||||
|
||||
if (!reachedBoundary)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "calcSamples : Reached end of samples: "
|
||||
<< " samplePt now:" << samplePt
|
||||
<< " sampleI now:" << sampleI
|
||||
<< endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
bool foundValidB = false;
|
||||
|
||||
while (bHitI < bHits.size())
|
||||
{
|
||||
scalar dist =
|
||||
(bHits[bHitI].hitPoint() - singleParticle.position())
|
||||
& normOffset;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Finding next boundary : "
|
||||
<< "bPoint:" << bHits[bHitI].hitPoint()
|
||||
<< " tracking:" << singleParticle.position()
|
||||
<< " dist:" << dist
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (dist > smallDist)
|
||||
{
|
||||
// hitpoint is past tracking position
|
||||
foundValidB = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
bHitI++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundValidB)
|
||||
{
|
||||
// No valid boundary intersection found beyond tracking position
|
||||
break;
|
||||
}
|
||||
|
||||
// Update starting point for tracking
|
||||
trackFaceI = bFaceI;
|
||||
trackPt = pushIn(bPoint, trackFaceI);
|
||||
trackCellI = getBoundaryCell(trackFaceI);
|
||||
|
||||
segmentI++;
|
||||
|
||||
startSegmentI = samplingPts.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::uniformSet::genSamples()
|
||||
{
|
||||
// Storage for sample points
|
||||
DynamicList<point> samplingPts;
|
||||
DynamicList<label> samplingCells;
|
||||
DynamicList<label> samplingFaces;
|
||||
DynamicList<label> samplingSegments;
|
||||
DynamicList<scalar> samplingCurveDist;
|
||||
|
||||
calcSamples
|
||||
(
|
||||
samplingPts,
|
||||
samplingCells,
|
||||
samplingFaces,
|
||||
samplingSegments,
|
||||
samplingCurveDist
|
||||
);
|
||||
|
||||
samplingPts.shrink();
|
||||
samplingCells.shrink();
|
||||
samplingFaces.shrink();
|
||||
samplingSegments.shrink();
|
||||
samplingCurveDist.shrink();
|
||||
|
||||
setSamples
|
||||
(
|
||||
samplingPts,
|
||||
samplingCells,
|
||||
samplingFaces,
|
||||
samplingSegments,
|
||||
samplingCurveDist
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::uniformSet::uniformSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const point& start,
|
||||
const point& end,
|
||||
const label nPoints
|
||||
)
|
||||
:
|
||||
sampleSet(mesh, searchEngine, name, axis),
|
||||
start_(start),
|
||||
end_(end),
|
||||
nPoints_(nPoints)
|
||||
{
|
||||
genSamples();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
write(Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Construct from dictionary
|
||||
Foam::uniformSet::uniformSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
sampleSet(mesh, searchEngine, dict),
|
||||
start_(dict.lookup("start")),
|
||||
end_(dict.lookup("end")),
|
||||
nPoints_(readLabel(dict.lookup("nPoints")))
|
||||
{
|
||||
genSamples();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
write(Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::uniformSet::~uniformSet()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
Foam::point Foam::uniformSet::getRefPoint(const List<point>& pts) const
|
||||
{
|
||||
// Use start point as reference for 'distance'
|
||||
return start_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,160 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::uniformSet
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
uniformSet.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef uniformSet_H
|
||||
#define uniformSet_H
|
||||
|
||||
#include "sampleSet.H"
|
||||
#include "DynamicList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class passiveParticle;
|
||||
template<class Type> class Particle;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class uniformSet Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class uniformSet
|
||||
:
|
||||
public sampleSet
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Starting point
|
||||
point start_;
|
||||
|
||||
//- End point
|
||||
point end_;
|
||||
|
||||
//- Number of points
|
||||
label nPoints_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculates - starting at samplePt - the first sampling point
|
||||
// on or after currentPt. smallDist is the tolerance used to compare
|
||||
// positions. Returns false if end of samples reached.
|
||||
bool nextSample
|
||||
(
|
||||
const point& currentPt,
|
||||
const vector& offset,
|
||||
const scalar smallDist,
|
||||
point& samplePt,
|
||||
label& sampleI
|
||||
) const;
|
||||
|
||||
//- Samples from startTrackPt/CellI. Updates particle/samplePt/sampleI
|
||||
// and puts
|
||||
// samples in the DynamicLists. Returns false if end of all samples
|
||||
// reached
|
||||
bool trackToBoundary
|
||||
(
|
||||
Particle<passiveParticle>& singleParticle,
|
||||
point& samplePt,
|
||||
label& sampleI,
|
||||
DynamicList<point>& samplingPts,
|
||||
DynamicList<label>& samplingCells,
|
||||
DynamicList<label>& samplingFaces,
|
||||
DynamicList<scalar>& samplingCurveDist
|
||||
) const;
|
||||
|
||||
//- Samples from start_ to end_. samplingSegments contains segmentNo
|
||||
// for each sample.
|
||||
void calcSamples
|
||||
(
|
||||
DynamicList<point>& samplingPts,
|
||||
DynamicList<label>& samplingCells,
|
||||
DynamicList<label>& samplingFaces,
|
||||
DynamicList<label>& samplingSegments,
|
||||
DynamicList<scalar>& samplingCurveDist
|
||||
) const;
|
||||
|
||||
//- Uses calcSamples to obtain samples. Copies them into *this.
|
||||
void genSamples();
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("uniform");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
uniformSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& axis,
|
||||
const point& start,
|
||||
const point& end,
|
||||
const label nPoints
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
uniformSet
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~uniformSet();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Get reference point
|
||||
virtual point getRefPoint(const List<point>&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,158 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "meshSearch.H"
|
||||
#include "interpolation.H"
|
||||
#include "volPointInterpolation.H"
|
||||
#include "PtrList.H"
|
||||
|
||||
#include "writer.H"
|
||||
#include "sampleSet.H"
|
||||
#include "volFieldSampler.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
# include "createMesh.H"
|
||||
|
||||
|
||||
//
|
||||
// 1. Sampling and writing.
|
||||
//
|
||||
|
||||
// Set up mesh searching
|
||||
meshSearch searchEngine(mesh, true);
|
||||
|
||||
// Construct sample points generator
|
||||
dictionary sampleDict;
|
||||
sampleDict.add("name", "lineX1");
|
||||
sampleDict.add("axis", "distance");
|
||||
sampleDict.add("start", point(0.02, 0.051, 0.005));
|
||||
sampleDict.add("end", point(0.06, 0.051, 0.005));
|
||||
sampleDict.add("nPoints", 10);
|
||||
|
||||
PtrList<sampleSet> sampleSets(1);
|
||||
sampleSets.set
|
||||
(
|
||||
0,
|
||||
sampleSet::New
|
||||
(
|
||||
"uniform",
|
||||
mesh,
|
||||
searchEngine,
|
||||
sampleDict
|
||||
).ptr()
|
||||
);
|
||||
|
||||
// Load field
|
||||
volScalarField sField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"p",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
// Set up interpolation
|
||||
pointMesh pMesh(mesh);
|
||||
volPointInterpolation pInterp(mesh, pMesh);
|
||||
|
||||
|
||||
// Do actual sampling
|
||||
dictionary interpolationSchemes;
|
||||
interpolationSchemes.add("p", "cell");
|
||||
|
||||
volFieldSampler<scalar> sampleVals
|
||||
(
|
||||
pInterp,
|
||||
interpolationSchemes,
|
||||
sField,
|
||||
sampleSets
|
||||
);
|
||||
|
||||
// Construct writer and write
|
||||
autoPtr<writer<scalar> > scalarFormatter(writer<scalar>::New("xmgr"));
|
||||
|
||||
scalarFormatter().write
|
||||
(
|
||||
".",
|
||||
sampleSets[0],
|
||||
sampleVals.name(),
|
||||
sampleVals[0]
|
||||
);
|
||||
|
||||
|
||||
|
||||
//
|
||||
// 2. No sampling, just using writing
|
||||
//
|
||||
List<point> points(5);
|
||||
points[0] = point(0, 0, 0);
|
||||
points[1] = point(1, 1, 1);
|
||||
points[2] = point(2, 2, 2);
|
||||
points[3] = point(3, 3, 3);
|
||||
points[4] = point(4, 4, 4);
|
||||
|
||||
scalarList vals(5);
|
||||
vals[0] = 0.0;
|
||||
vals[1] = 0.1;
|
||||
vals[2] = 0.2;
|
||||
vals[3] = 0.3;
|
||||
vals[4] = 0.4;
|
||||
|
||||
|
||||
scalarFormatter().write
|
||||
(
|
||||
".",
|
||||
coordSet
|
||||
(
|
||||
"someLine",
|
||||
"distance",
|
||||
points,
|
||||
points[0]
|
||||
),
|
||||
"U.component(0)",
|
||||
vals
|
||||
);
|
||||
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,91 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "volFieldSampler.H"
|
||||
#include "volPointInterpolation.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
template <class Type>
|
||||
Foam::volFieldSampler<Type>::volFieldSampler
|
||||
(
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field,
|
||||
const PtrList<sampleSet>& samplers
|
||||
)
|
||||
:
|
||||
List<Field<Type> >(samplers.size()),
|
||||
name_(field.name())
|
||||
{
|
||||
autoPtr<interpolation<Type> > interpolator
|
||||
(
|
||||
interpolation<Type>::New(interpolationSchemes, pInterp, field)
|
||||
);
|
||||
|
||||
forAll(samplers, setI)
|
||||
{
|
||||
Field<Type>& values = this->operator[](setI);
|
||||
|
||||
const sampleSet& samples = samplers[setI];
|
||||
|
||||
values.setSize(samples.size());
|
||||
forAll(samples, sampleI)
|
||||
{
|
||||
const point& samplePt = samples[sampleI];
|
||||
label cellI = samples.cells()[sampleI];
|
||||
label faceI = samples.faces()[sampleI];
|
||||
|
||||
values[sampleI] =
|
||||
interpolator().interpolate
|
||||
(
|
||||
samplePt,
|
||||
cellI,
|
||||
faceI
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Construct from components
|
||||
template <class Type>
|
||||
Foam::volFieldSampler<Type>::volFieldSampler
|
||||
(
|
||||
const List<Field<Type> >& values,
|
||||
const word& name
|
||||
)
|
||||
:
|
||||
List<Field<Type> >(values),
|
||||
name_(name)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,109 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::volFieldSampler
|
||||
|
||||
Description
|
||||
Samples a volField given a list of sampleSets (i.e. points).
|
||||
|
||||
SourceFiles
|
||||
volFieldSampler.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef volFieldSampler_H
|
||||
#define volFieldSampler_H
|
||||
|
||||
#include "sampleSet.H"
|
||||
#include "List.H"
|
||||
#include "PtrList.H"
|
||||
#include "volFields.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class volPointInterpolation;
|
||||
class dictionary;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class volFieldSampler Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template <class Type>
|
||||
class volFieldSampler
|
||||
:
|
||||
public List<Field<Type> >
|
||||
{
|
||||
//- Name of this collection of values
|
||||
const word name_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from sampleSet, interpolator, Field
|
||||
volFieldSampler
|
||||
(
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes,
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field,
|
||||
const PtrList<sampleSet>&
|
||||
);
|
||||
|
||||
//- Construct from components
|
||||
volFieldSampler
|
||||
(
|
||||
const List<Field<Type> >& values,
|
||||
const word& name
|
||||
);
|
||||
|
||||
// Member functions
|
||||
|
||||
const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "volFieldSampler.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,100 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "gnuplot.H"
|
||||
#include "clock.H"
|
||||
#include "coordSet.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
template<class Type>
|
||||
Foam::gnuplot<Type>::gnuplot()
|
||||
:
|
||||
writer<Type>()
|
||||
{}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::gnuplot<Type>::~gnuplot()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::fileName Foam::gnuplot<Type>::getFileName
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames
|
||||
) const
|
||||
{
|
||||
return this->getBaseName(points, valueSetNames) + ".gplt";
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::gnuplot<Type>::write
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames,
|
||||
const List<const Field<Type>*>& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << "set term postscript color" << endl
|
||||
<< "set output \"" << points.name() << ".ps\"" << endl
|
||||
<< "plot";
|
||||
|
||||
bool firstField = true;
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
if (!firstField)
|
||||
{
|
||||
os << ',';
|
||||
}
|
||||
firstField = false;
|
||||
|
||||
os << "'-' title \"" << valueSetNames[i] << "\" with lines";
|
||||
}
|
||||
os << endl;
|
||||
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
os << endl;
|
||||
writeTable(points, *valueSets[i], os);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,105 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::gnuplot
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
gnuplot.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef gnuplot_H
|
||||
#define gnuplot_H
|
||||
|
||||
#include "writer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class gnuplot Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class gnuplot
|
||||
:
|
||||
public writer<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("gnuplot");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
gnuplot();
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~gnuplot();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
|
||||
virtual fileName getFileName
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&
|
||||
) const;
|
||||
|
||||
void write
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&,
|
||||
const List<const Field<Type>*>&,
|
||||
Ostream& os
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "gnuplot.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,45 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "gnuplotWriters.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeWriters(gnuplot);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,62 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::gnuplotWriters
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
gnuplotWriters.C
|
||||
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef gnuplotWriters_H
|
||||
#define gnuplotWriters_H
|
||||
|
||||
#include "gnuplot.H"
|
||||
#include "writers.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef gnuplot<scalar> gnuplotScalarWriter;
|
||||
typedef gnuplot<vector> gnuplotVectorWriter;
|
||||
typedef gnuplot<tensor> gnuplotTensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,106 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "jplot.H"
|
||||
#include "clock.H"
|
||||
#include "coordSet.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Ostream& Foam::jplot<Type>::writeHeader(Ostream& os) const
|
||||
{
|
||||
return os
|
||||
<< "# JPlot input file" << endl
|
||||
<< "#" << endl
|
||||
<< endl
|
||||
<< "# Generated by sample on " << clock::date().c_str() << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
template<class Type>
|
||||
Foam::jplot<Type>::jplot()
|
||||
:
|
||||
writer<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::jplot<Type>::~jplot()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::fileName Foam::jplot<Type>::getFileName
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames
|
||||
) const
|
||||
{
|
||||
return this->getBaseName(points, valueSetNames) + ".dat";
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::jplot<Type>::write
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames,
|
||||
const List<const Field<Type>*>& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << "# JPlot file" << endl
|
||||
<< "# column 1: " << points.name() << endl;
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
os << "# column " << i + 2 << ": " << valueSetNames[i] << endl;
|
||||
}
|
||||
|
||||
// Collect sets into columns
|
||||
List<const List<Type>*> columns(valueSets.size());
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
columns[i] = valueSets[i];
|
||||
}
|
||||
|
||||
writeTable(points, columns, os);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,115 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::jplot
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
jplot.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef jplot_H
|
||||
#define jplot_H
|
||||
|
||||
#include "writer.H"
|
||||
#include "vector.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class jplot Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class jplot
|
||||
:
|
||||
public writer<Type>
|
||||
{
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Write header
|
||||
Ostream& writeHeader(Ostream& os) const;
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("jplot");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
jplot();
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~jplot();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
// Write
|
||||
|
||||
virtual fileName getFileName
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&
|
||||
) const;
|
||||
|
||||
void write
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&,
|
||||
const List<const Field<Type>*>&,
|
||||
Ostream& os
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "jplot.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,45 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "jplotWriters.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeWriters(jplot);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,62 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::jplotWriters
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
jplotWriters.C
|
||||
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef jplotWriters_H
|
||||
#define jplotWriters_H
|
||||
|
||||
#include "jplot.H"
|
||||
#include "writers.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef jplot<scalar> jplotScalarWriter;
|
||||
typedef jplot<vector> jplotVectorWriter;
|
||||
typedef jplot<tensor> jplotTensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,83 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "raw.H"
|
||||
#include "coordSet.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
template<class Type>
|
||||
Foam::raw<Type>::raw()
|
||||
:
|
||||
writer<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::raw<Type>::~raw()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::fileName Foam::raw<Type>::getFileName
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames
|
||||
) const
|
||||
{
|
||||
return this->getBaseName(points, valueSetNames) + ".xy";
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::write
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames,
|
||||
const List<const Field<Type>*>& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Collect sets into columns
|
||||
List<const List<Type>*> columns(valueSets.size());
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
columns[i] = valueSets[i];
|
||||
}
|
||||
|
||||
writeTable(points, columns, os);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,105 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::raw
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
raw.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef raw_H
|
||||
#define raw_H
|
||||
|
||||
#include "writer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class raw Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class raw
|
||||
:
|
||||
public writer<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("raw");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
raw();
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~raw();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
|
||||
virtual fileName getFileName
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&
|
||||
) const;
|
||||
|
||||
void write
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&,
|
||||
const List<const Field<Type>*>&,
|
||||
Ostream& os
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "raw.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,45 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rawWriters.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeWriters(raw);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,62 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::rawWriters
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
rawWriters.C
|
||||
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef rawWriters_H
|
||||
#define rawWriters_H
|
||||
|
||||
#include "raw.H"
|
||||
#include "writers.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef raw<scalar> rawScalarWriter;
|
||||
typedef raw<vector> rawVectorWriter;
|
||||
typedef raw<tensor> rawTensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,205 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "writer.H"
|
||||
#include "coordSet.H"
|
||||
#include "OFstream.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
template<class Type>
|
||||
autoPtr<writer<Type> > writer<Type>::New(const word& writeType)
|
||||
{
|
||||
typename wordConstructorTable::iterator cstrIter =
|
||||
wordConstructorTablePtr_
|
||||
->find(writeType);
|
||||
|
||||
if (cstrIter == wordConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"writer::New(const word&)"
|
||||
) << "Unknown write type " << writeType
|
||||
<< endl << endl
|
||||
<< "Valid write types : " << endl
|
||||
<< wordConstructorTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<writer<Type> >(cstrIter()());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
fileName writer<Type>::getBaseName
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSets
|
||||
) const
|
||||
{
|
||||
fileName fName(points.name());
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
fName += '_' + valueSets[i];
|
||||
}
|
||||
|
||||
return fName;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void writer<Type>::writeCoord
|
||||
(
|
||||
const coordSet& points,
|
||||
const label pointI,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
if (points.hasVectorAxis())
|
||||
{
|
||||
write(points.vectorCoord(pointI), os);
|
||||
}
|
||||
else
|
||||
{
|
||||
write(points.scalarCoord(pointI), os);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void writer<Type>::writeTable
|
||||
(
|
||||
const coordSet& points,
|
||||
const List<Type>& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
forAll(points, pointI)
|
||||
{
|
||||
writeCoord(points, pointI, os);
|
||||
|
||||
os << token::SPACE;
|
||||
|
||||
write(values[pointI], os);
|
||||
|
||||
os << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void writer<Type>::writeTable
|
||||
(
|
||||
const coordSet& points,
|
||||
const List<const List<Type>*>& valuesPtrList,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
forAll(points, pointI)
|
||||
{
|
||||
writeCoord(points, pointI, os);
|
||||
|
||||
forAll(valuesPtrList, i)
|
||||
{
|
||||
os << token::SPACE;
|
||||
|
||||
const List<Type>& values = *valuesPtrList[i];
|
||||
|
||||
write(values[pointI], os);
|
||||
}
|
||||
os << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct null
|
||||
template<class Type>
|
||||
writer<Type>::writer()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
writer<Type>::~writer()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Ostream& Foam::writer<Type>::write(const scalar value, Ostream& os) const
|
||||
{
|
||||
return os << value;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Ostream& Foam::writer<Type>::write(const vector& value, Ostream& os) const
|
||||
{
|
||||
for (direction d=0; d<vector::nComponents; d++)
|
||||
{
|
||||
os << value.component(d);
|
||||
|
||||
if (d <= vector::nComponents-1)
|
||||
{
|
||||
os << token::TAB;
|
||||
}
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Ostream& Foam::writer<Type>::write(const tensor& value, Ostream& os) const
|
||||
{
|
||||
for (direction d=0; d<tensor::nComponents; d++)
|
||||
{
|
||||
os << value.component(d);
|
||||
|
||||
if (d <= tensor::nComponents-1)
|
||||
{
|
||||
os << token::TAB;
|
||||
}
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,239 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::writer
|
||||
|
||||
Description
|
||||
base class for graphics format writing. Entry points are
|
||||
- write(..). Write to an Ostream a table of points with corresponding
|
||||
values.
|
||||
|
||||
- write(scalar/vector/tensor). Write single scalar/vector/tensor.
|
||||
Default is to write space separated components.
|
||||
|
||||
Example:
|
||||
|
||||
// Construct writer of xmgr type
|
||||
autoPtr<writer<scalar> > scalarFormatter(writer<scalar>::New("xmgr"));
|
||||
|
||||
// Output list of points and corresponding values
|
||||
scalarFormatter().write
|
||||
(
|
||||
coordSet
|
||||
(
|
||||
points, // sample coordinates
|
||||
"someLine", // name of coordSet
|
||||
"distance", // write coordinates as distance to refPoint
|
||||
points[0] // reference point
|
||||
),
|
||||
"U.component(0)", // name of values
|
||||
vals // values
|
||||
);
|
||||
|
||||
|
||||
SourceFiles
|
||||
writer.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writer_H
|
||||
#define writer_H
|
||||
|
||||
#include "fileName.H"
|
||||
#include "wordList.H"
|
||||
#include "vector.H"
|
||||
#include "tensor.H"
|
||||
#include "typeInfo.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "autoPtr.H"
|
||||
#include "Field.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class coordSet;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class writer Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class writer
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
//- Generates filename from coordSet and sampled fields
|
||||
fileName getBaseName(const coordSet&, const wordList&) const;
|
||||
|
||||
void writeCoord
|
||||
(
|
||||
const coordSet& samples,
|
||||
const label sampleI,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
//- Writes single-column ascii write. Column 1 is coordSet coordinate,
|
||||
// columns 2 is the value. Uses write() function
|
||||
// to write coordinate in correct format.
|
||||
void writeTable
|
||||
(
|
||||
const coordSet&,
|
||||
const List<Type>&,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
//- Writes multi-column ascii write. Column 1 is coordSet coordinate,
|
||||
// columns 2..n are the values. Uses write() function
|
||||
// to write coordinate in correct format.
|
||||
void writeTable
|
||||
(
|
||||
const coordSet&,
|
||||
const List<const List<Type>*>&,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("writer");
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
writer,
|
||||
word,
|
||||
(),
|
||||
()
|
||||
);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected writer
|
||||
static autoPtr<writer> New
|
||||
(
|
||||
const word& writeFormat
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
writer();
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~writer() = 0;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
// Write
|
||||
|
||||
//- Generate file name with correct extension
|
||||
virtual fileName getFileName
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&
|
||||
) const = 0;
|
||||
|
||||
//- General entry point for writing.
|
||||
// The data is organized in a set of point with one or
|
||||
// more values per point
|
||||
virtual void write
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&,
|
||||
const List<const Field<Type>*>&,
|
||||
Ostream&
|
||||
) const = 0;
|
||||
|
||||
//- Write scalar as ascii
|
||||
virtual Ostream& write(const scalar, Ostream&) const;
|
||||
|
||||
//- Write vector. Tab separated ascii
|
||||
virtual Ostream& write(const vector&, Ostream&) const;
|
||||
|
||||
//- Write tensor. Tab separated ascii
|
||||
virtual Ostream& write(const tensor&, Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "writer.C"
|
||||
#endif
|
||||
|
||||
// Only used internally
|
||||
#define makeTypeWritersTypeName(type) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(type, 0);
|
||||
|
||||
// Used externally sometimes
|
||||
#define makeWritersTypeName(typeWriter) \
|
||||
\
|
||||
makeTypeWritersTypeName(typeWriter##ScalarWriter); \
|
||||
makeTypeWritersTypeName(typeWriter##VectorWriter); \
|
||||
makeTypeWritersTypeName(typeWriter##TensorWriter);
|
||||
|
||||
// Define type info for single template instantiation (e.g. vector)
|
||||
#define makeWriterTypes(WriterType, type) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(type, 0); \
|
||||
\
|
||||
addToRunTimeSelectionTable \
|
||||
( \
|
||||
WriterType, type, word \
|
||||
);
|
||||
|
||||
|
||||
// Define type info info for scalar, vector etc. instantiations
|
||||
#define makeWriters(typeWriter) \
|
||||
\
|
||||
makeWriterTypes(scalarWriter, typeWriter##ScalarWriter); \
|
||||
makeWriterTypes(vectorWriter, typeWriter##VectorWriter); \
|
||||
makeWriterTypes(tensorWriter, typeWriter##TensorWriter);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,57 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "writers.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineNamedTemplateTypeNameAndDebug(scalarWriter, 0);
|
||||
defineTemplateRunTimeSelectionTable(scalarWriter, word);
|
||||
|
||||
defineNamedTemplateTypeNameAndDebug(vectorWriter, 0);
|
||||
defineTemplateRunTimeSelectionTable(vectorWriter, word);
|
||||
|
||||
defineNamedTemplateTypeNameAndDebug(sphericalTensorWriter, 0);
|
||||
defineTemplateRunTimeSelectionTable(sphericalTensorWriter, word);
|
||||
|
||||
defineNamedTemplateTypeNameAndDebug(symmTensorWriter, 0);
|
||||
defineTemplateRunTimeSelectionTable(symmTensorWriter, word);
|
||||
|
||||
defineNamedTemplateTypeNameAndDebug(tensorWriter, 0);
|
||||
defineTemplateRunTimeSelectionTable(tensorWriter, word);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,59 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::writer
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writers_H
|
||||
#define writers_H
|
||||
|
||||
#include "writer.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef writer<scalar> scalarWriter;
|
||||
typedef writer<vector> vectorWriter;
|
||||
typedef writer<sphericalTensor> sphericalTensorWriter;
|
||||
typedef writer<symmTensor> symmTensorWriter;
|
||||
typedef writer<tensor> tensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,89 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "xmgr.H"
|
||||
#include "coordSet.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
template<class Type>
|
||||
Foam::xmgr<Type>::xmgr()
|
||||
:
|
||||
writer<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::xmgr<Type>::~xmgr()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::fileName Foam::xmgr<Type>::getFileName
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames
|
||||
) const
|
||||
{
|
||||
return this->getBaseName(points, valueSetNames) + ".agr";
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::xmgr<Type>::write
|
||||
(
|
||||
const coordSet& points,
|
||||
const wordList& valueSetNames,
|
||||
const List<const Field<Type>*>& valueSets,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << "@title \"" << points.name() << '"' << endl
|
||||
<< "@xaxis label " << '"' << points.axis() << '"' << endl;
|
||||
|
||||
forAll(valueSets, i)
|
||||
{
|
||||
os << "@s" << i << " legend " << '"'
|
||||
<< valueSetNames[i] << '"' << endl
|
||||
<< "@target G0.S" << i << endl
|
||||
<< "@type xy" << endl;
|
||||
|
||||
writeTable(points, *valueSets[i], os);
|
||||
|
||||
os << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,105 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::xmgr
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
xmgr.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef xmgr_H
|
||||
#define xmgr_H
|
||||
|
||||
#include "writer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class xmgr Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class xmgr
|
||||
:
|
||||
public writer<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("xmgr");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
xmgr();
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~xmgr();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
|
||||
virtual fileName getFileName
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&
|
||||
) const;
|
||||
|
||||
void write
|
||||
(
|
||||
const coordSet&,
|
||||
const wordList&,
|
||||
const List<const Field<Type>*>&,
|
||||
Ostream& os
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "xmgr.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,45 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "xmgrWriters.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeWriters(xmgr);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,18 +0,0 @@
|
||||
sampleSurface.C
|
||||
|
||||
surfaces/surface/surface.C
|
||||
surfaces/constantIsoSurface/constantIsoSurface.C
|
||||
surfaces/interpolatedIsoSurface/interpolatedIsoSurface.C
|
||||
surfaces/constantPatch/constantPatch.C
|
||||
surfaces/interpolatedPatch/interpolatedPatch.C
|
||||
surfaces/constantPlane/constantPlane.C
|
||||
surfaces/interpolatedPlane/interpolatedPlane.C
|
||||
|
||||
surfaceWriters/surfaceWriter/surfaceWriters.C
|
||||
surfaceWriters/foamFile/foamFileWriters.C
|
||||
surfaceWriters/dx/dxWriters.C
|
||||
surfaceWriters/raw/rawWriters.C
|
||||
surfaceWriters/vtk/vtkWriters.C
|
||||
surfaceWriters/stl/stlWriters.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/sampleSurface
|
||||
@ -1,105 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldsCache.H"
|
||||
#include "volPointInterpolation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::fieldsCache<Type>::fieldsCache()
|
||||
:
|
||||
HashPtrTable<GeometricField<Type, fvPatchField, volMesh> >(),
|
||||
pointFields_(),
|
||||
interpolators_()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Foam::GeometricField<Type, Foam::pointPatchField, Foam::pointMesh>&
|
||||
Foam::fieldsCache<Type>::pointField
|
||||
(
|
||||
const word& name,
|
||||
const volPointInterpolation& pInterp
|
||||
) const
|
||||
{
|
||||
if (!pointFields_.found(name))
|
||||
{
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField =
|
||||
*this->operator[](name);
|
||||
|
||||
tmp<GeometricField<Type, pointPatchField, pointMesh> > tptField =
|
||||
pInterp.interpolate(vField);
|
||||
|
||||
GeometricField<Type, pointPatchField, pointMesh>* ptFieldPtr =
|
||||
tptField.ptr();
|
||||
|
||||
pointFields_.insert(name, ptFieldPtr);
|
||||
|
||||
return *ptFieldPtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return *pointFields_[name];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
const Foam::interpolation<Type>& Foam::fieldsCache<Type>::interpolator
|
||||
(
|
||||
const word& name,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
if (!interpolators_.found(name))
|
||||
{
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField =
|
||||
*this->operator[](name);
|
||||
|
||||
interpolation<Type>* interpolatorPtr =
|
||||
interpolation<Type>::New
|
||||
(
|
||||
interpolationSchemes,
|
||||
pInterp,
|
||||
vField
|
||||
).ptr();
|
||||
|
||||
interpolators_.insert(name, interpolatorPtr);
|
||||
|
||||
return *interpolatorPtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return *interpolators_[name];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,109 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::fieldsCache
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
fieldsCache.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fieldsCache_H
|
||||
#define fieldsCache_H
|
||||
|
||||
#include "volFields.H"
|
||||
#include "pointFields.H"
|
||||
#include "HashPtrTable.H"
|
||||
#include "interpolation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fieldsCache Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class fieldsCache
|
||||
:
|
||||
public HashPtrTable<GeometricField<Type, fvPatchField, volMesh> >
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
//- Cached pointFields
|
||||
mutable HashPtrTable<GeometricField<Type, pointPatchField, pointMesh> >
|
||||
pointFields_;
|
||||
|
||||
//- Cached interpolators
|
||||
mutable HashPtrTable<interpolation<Type> > interpolators_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
fieldsCache();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Get pointField of named field
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& pointField
|
||||
(
|
||||
const word&,
|
||||
const volPointInterpolation& pInterp
|
||||
) const;
|
||||
|
||||
//- Get interpolator for named field
|
||||
const interpolation<Type>& interpolator
|
||||
(
|
||||
const word&,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "fieldsCache.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,842 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "OSspecific.H"
|
||||
#include "meshSearch.H"
|
||||
#include "interpolation.H"
|
||||
#include "volPointInterpolation.H"
|
||||
#include "cuttingPlane.H"
|
||||
#include "OFstream.H"
|
||||
#include "Pstream.H"
|
||||
#include "ListListOps.H"
|
||||
#include "Cloud.H"
|
||||
#include "passiveParticle.H"
|
||||
#include "mergePoints.H"
|
||||
|
||||
#include "fieldsCache.H"
|
||||
#include "surface.H"
|
||||
#include "surfaceWriter.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Used to offset faces in Pstream::combineOffset
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
template <>
|
||||
class offsetOp<face>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
face operator()
|
||||
(
|
||||
const face& x,
|
||||
const label offset
|
||||
) const
|
||||
{
|
||||
face result(x.size());
|
||||
|
||||
forAll(x, xI)
|
||||
{
|
||||
result[xI] = x[xI] + offset;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
void mergePoints
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const scalar mergeTol,
|
||||
List<pointField>& allPoints,
|
||||
List<faceList>& allFaces,
|
||||
labelListList& allOldToNew
|
||||
)
|
||||
{
|
||||
const boundBox& bb = mesh.globalData().bb();
|
||||
|
||||
scalar mergeDim = mergeTol * mag(bb.max() - bb.min());
|
||||
|
||||
Info<< nl << "Merging all points within " << mergeDim << " meter." << endl;
|
||||
|
||||
allOldToNew.setSize(allPoints.size());
|
||||
|
||||
forAll(allPoints, surfaceI)
|
||||
{
|
||||
pointField newPoints;
|
||||
labelList oldToNew;
|
||||
|
||||
bool hasMerged = mergePoints
|
||||
(
|
||||
allPoints[surfaceI],
|
||||
mergeDim,
|
||||
false, // verbosity
|
||||
oldToNew,
|
||||
newPoints
|
||||
);
|
||||
|
||||
if (hasMerged)
|
||||
{
|
||||
// Copy points
|
||||
allPoints[surfaceI].transfer(newPoints);
|
||||
|
||||
// Store point mapping
|
||||
allOldToNew[surfaceI].transfer(oldToNew);
|
||||
|
||||
// Relabel faces.
|
||||
faceList& faces = allFaces[surfaceI];
|
||||
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
inplaceRenumber(allOldToNew[surfaceI], faces[faceI]);
|
||||
}
|
||||
|
||||
Info<< "For surface " << surfaceI << " merged from "
|
||||
<< allOldToNew[surfaceI].size() << " points down to "
|
||||
<< allPoints[surfaceI].size() << " points." << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void renumberData
|
||||
(
|
||||
const labelList& oldToNewPoints,
|
||||
const label newSize,
|
||||
Field<T>& values
|
||||
)
|
||||
{
|
||||
if (oldToNewPoints.size() == values.size())
|
||||
{
|
||||
inplaceReorder(oldToNewPoints, values);
|
||||
values.setSize(newSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
# include "addTimeOptions.H"
|
||||
# include "setRootCase.H"
|
||||
|
||||
# include "createTime.H"
|
||||
|
||||
// Get times list
|
||||
instantList Times = runTime.times();
|
||||
|
||||
// set startTime and endTime depending on -time and -latestTime options
|
||||
# include "checkTimeOptions.H"
|
||||
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
|
||||
# include "createMesh.H"
|
||||
|
||||
|
||||
//
|
||||
// Hack: initialize Cloud to initialize the processor table so from
|
||||
// now on we can use cloud (in meshSearch) on single processors only.
|
||||
//
|
||||
Cloud<passiveParticle> dummyCloud(mesh, IDLList<passiveParticle>());
|
||||
|
||||
//
|
||||
// Read control dictionary
|
||||
//
|
||||
|
||||
IOdictionary sampleDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"sampleSurfaceDict",
|
||||
runTime.system(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
const word interpolationScheme(sampleDict.lookup("interpolationScheme"));
|
||||
const wordList fieldNames = sampleDict.lookup("fields");
|
||||
|
||||
//
|
||||
// Construct writers
|
||||
//
|
||||
|
||||
word writeFormat(sampleDict.lookup("surfaceFormat"));
|
||||
|
||||
autoPtr<surfaceWriter<scalar> > scalarFormatter
|
||||
(
|
||||
surfaceWriter<scalar>::New(writeFormat)
|
||||
);
|
||||
autoPtr<surfaceWriter<vector> > vectorFormatter
|
||||
(
|
||||
surfaceWriter<vector>::New(writeFormat)
|
||||
);
|
||||
autoPtr<surfaceWriter<sphericalTensor> > sphericalTensorFormatter
|
||||
(
|
||||
surfaceWriter<sphericalTensor>::New(writeFormat)
|
||||
);
|
||||
autoPtr<surfaceWriter<symmTensor> > symmTensorFormatter
|
||||
(
|
||||
surfaceWriter<symmTensor>::New(writeFormat)
|
||||
);
|
||||
autoPtr<surfaceWriter<tensor> > tensorFormatter
|
||||
(
|
||||
surfaceWriter<tensor>::New(writeFormat)
|
||||
);
|
||||
|
||||
//
|
||||
// Construct interpolation dictionary (same interpolation for all fields)
|
||||
//
|
||||
|
||||
dictionary interpolationSchemes;
|
||||
|
||||
forAll(fieldNames, fieldI)
|
||||
{
|
||||
interpolationSchemes.add
|
||||
(
|
||||
fieldNames[fieldI],
|
||||
interpolationScheme
|
||||
);
|
||||
}
|
||||
|
||||
fileName samplePath;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
samplePath = runTime.path()/".."/"sampleSurfaces";
|
||||
}
|
||||
else
|
||||
{
|
||||
samplePath = runTime.path()/"sampleSurfaces";
|
||||
}
|
||||
|
||||
if (Pstream::master() && exists(samplePath))
|
||||
{
|
||||
Info<< "Deleting sampleSurfaces/ directory" << endl << endl;
|
||||
rmDir(samplePath);
|
||||
}
|
||||
|
||||
// Set up interpolation
|
||||
autoPtr<pointMesh> pMeshPtr(new pointMesh(mesh));
|
||||
autoPtr<volPointInterpolation> pInterpPtr
|
||||
(
|
||||
new volPointInterpolation(mesh, pMeshPtr())
|
||||
);
|
||||
|
||||
// Set up mesh searching
|
||||
meshSearch searchEngine(mesh, true);
|
||||
|
||||
// Create sample surfaces
|
||||
PtrList<surface> surfaces
|
||||
(
|
||||
sampleDict.lookup("surfaces"),
|
||||
surface::iNew(mesh, searchEngine)
|
||||
);
|
||||
Info<< endl;
|
||||
|
||||
|
||||
fileName oldPointsDir("constant");
|
||||
|
||||
|
||||
for (label i=startTime; i<endTime; i++)
|
||||
{
|
||||
runTime.setTime(Times[i], i);
|
||||
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
//
|
||||
// Handle geometry/topology changes
|
||||
//
|
||||
polyMesh::readUpdateState state = mesh.readUpdate();
|
||||
|
||||
bool meshChanged = false;
|
||||
|
||||
if
|
||||
(
|
||||
state == polyMesh::POINTS_MOVED
|
||||
|| state == polyMesh::TOPO_CHANGE
|
||||
)
|
||||
{
|
||||
// Geometry and topology changes
|
||||
searchEngine.correct();
|
||||
|
||||
pMeshPtr.reset(new pointMesh(mesh));
|
||||
|
||||
pInterpPtr.reset(new volPointInterpolation(mesh, pMeshPtr()));
|
||||
|
||||
meshChanged = true;
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
Info<< "Creating directory " << samplePath/runTime.timeName()
|
||||
<< endl << endl;
|
||||
|
||||
mkDir(samplePath/runTime.timeName());
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Cache used fields and interpolators
|
||||
//
|
||||
|
||||
fieldsCache<scalar> scalarCache;
|
||||
fieldsCache<vector> vectorCache;
|
||||
fieldsCache<sphericalTensor> sphericalTensorCache;
|
||||
fieldsCache<symmTensor> symmTensorCache;
|
||||
fieldsCache<tensor> tensorCache;
|
||||
|
||||
forAll(fieldNames, fieldI)
|
||||
{
|
||||
const word& fieldName = fieldNames[fieldI];
|
||||
|
||||
IOobject fieldHeader
|
||||
(
|
||||
fieldName,
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
if (fieldHeader.headerOk())
|
||||
{
|
||||
if
|
||||
(
|
||||
fieldHeader.headerClassName() == volScalarField::typeName
|
||||
)
|
||||
{
|
||||
Info<< "Loading " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volScalarField* fieldPtr
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
fieldHeader,
|
||||
mesh
|
||||
)
|
||||
);
|
||||
|
||||
scalarCache.insert(fieldName, fieldPtr);
|
||||
}
|
||||
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerClassName() == volVectorField::typeName
|
||||
)
|
||||
{
|
||||
Info<< "Loading " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volVectorField* fieldPtr
|
||||
(
|
||||
new volVectorField
|
||||
(
|
||||
fieldHeader,
|
||||
mesh
|
||||
)
|
||||
);
|
||||
|
||||
vectorCache.insert(fieldName, fieldPtr);
|
||||
}
|
||||
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerClassName()
|
||||
== volSphericalTensorField::typeName
|
||||
)
|
||||
{
|
||||
Info<< "Loading " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volSphericalTensorField* fieldPtr
|
||||
(
|
||||
new volSphericalTensorField
|
||||
(
|
||||
fieldHeader,
|
||||
mesh
|
||||
)
|
||||
);
|
||||
|
||||
sphericalTensorCache.insert(fieldName, fieldPtr);
|
||||
}
|
||||
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerClassName()
|
||||
== volSymmTensorField::typeName
|
||||
)
|
||||
{
|
||||
Info<< "Loading " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volSymmTensorField* fieldPtr
|
||||
(
|
||||
new volSymmTensorField
|
||||
(
|
||||
fieldHeader,
|
||||
mesh
|
||||
)
|
||||
);
|
||||
|
||||
symmTensorCache.insert(fieldName, fieldPtr);
|
||||
}
|
||||
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerClassName() == volTensorField::typeName
|
||||
)
|
||||
{
|
||||
Info<< "Loading " << fieldHeader.headerClassName()
|
||||
<< ' ' << fieldName << endl;
|
||||
|
||||
volTensorField* fieldPtr
|
||||
(
|
||||
new volTensorField
|
||||
(
|
||||
fieldHeader,
|
||||
mesh
|
||||
)
|
||||
);
|
||||
|
||||
tensorCache.insert(fieldName, fieldPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Now we have fields cached and know whether mesh has changed.
|
||||
// Update surfaces with this information.
|
||||
//
|
||||
|
||||
forAll(surfaces, surfaceI)
|
||||
{
|
||||
surfaces[surfaceI].correct
|
||||
(
|
||||
meshChanged,
|
||||
pInterpPtr,
|
||||
interpolationSchemes,
|
||||
scalarCache
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Combine surfaces onto master (bug:should not be redone for static
|
||||
// meshes)
|
||||
//
|
||||
|
||||
List<pointField> allPoints(surfaces.size());
|
||||
List<faceList> allFaces(surfaces.size());
|
||||
|
||||
forAll(surfaces, surfaceI)
|
||||
{
|
||||
// Collect points from all processors
|
||||
List<pointField> gatheredPoints(Pstream::nProcs());
|
||||
gatheredPoints[Pstream::myProcNo()] = surfaces[surfaceI].points();
|
||||
Pstream::gatherList(gatheredPoints);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
allPoints[surfaceI] = ListListOps::combine<pointField>
|
||||
(
|
||||
gatheredPoints,
|
||||
accessOp<pointField>()
|
||||
);
|
||||
}
|
||||
|
||||
// Collect faces from all processors and renumber using sizes of
|
||||
// gathered points
|
||||
List<faceList> gatheredFaces(Pstream::nProcs());
|
||||
gatheredFaces[Pstream::myProcNo()] = surfaces[surfaceI].faces();
|
||||
Pstream::gatherList(gatheredFaces);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
allFaces[surfaceI] = static_cast<const faceList&>
|
||||
(
|
||||
ListListOps::combineOffset<faceList>
|
||||
(
|
||||
gatheredFaces,
|
||||
ListListOps::subSizes
|
||||
(
|
||||
gatheredPoints,
|
||||
accessOp<pointField>()
|
||||
),
|
||||
accessOp<faceList>(),
|
||||
offsetOp<face>()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Merge close points (1E-10 of mesh bounding box)
|
||||
labelListList allOldToNewPoints;
|
||||
mergePoints(mesh, 1E-10, allPoints, allFaces, allOldToNewPoints);
|
||||
|
||||
|
||||
//
|
||||
// Do actual interpolation
|
||||
//
|
||||
|
||||
forAll(fieldNames, fieldI)
|
||||
{
|
||||
Info<< endl;
|
||||
|
||||
const word& fieldName = fieldNames[fieldI];
|
||||
|
||||
// Scalar fields
|
||||
|
||||
if (scalarCache.found(fieldName))
|
||||
{
|
||||
Info<< "Sampling volScalarField " << fieldName << endl << endl;
|
||||
|
||||
forAll(surfaces, surfaceI)
|
||||
{
|
||||
const surface& s = surfaces[surfaceI];
|
||||
|
||||
scalarField values
|
||||
(
|
||||
s.interpolate
|
||||
(
|
||||
fieldName,
|
||||
scalarCache,
|
||||
pInterpPtr,
|
||||
interpolationSchemes
|
||||
)
|
||||
);
|
||||
|
||||
// Collect values from all processors
|
||||
List<scalarField> gatheredValues(Pstream::nProcs());
|
||||
gatheredValues[Pstream::myProcNo()] = values;
|
||||
Pstream::gatherList(gatheredValues);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Combine values into single field
|
||||
scalarField allValues
|
||||
(
|
||||
ListListOps::combine<scalarField>
|
||||
(
|
||||
gatheredValues,
|
||||
accessOp<scalarField>()
|
||||
)
|
||||
);
|
||||
|
||||
// Renumber (point data) to correspond to merged points
|
||||
renumberData
|
||||
(
|
||||
allOldToNewPoints[surfaceI],
|
||||
allPoints[surfaceI].size(),
|
||||
allValues
|
||||
);
|
||||
|
||||
// Write to time directory under sampleSurfaces/
|
||||
scalarFormatter().write
|
||||
(
|
||||
samplePath,
|
||||
runTime.timeName(),
|
||||
s.name(),
|
||||
allPoints[surfaceI],
|
||||
allFaces[surfaceI],
|
||||
fieldName,
|
||||
allValues
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Vector fields
|
||||
|
||||
else if (vectorCache.found(fieldName))
|
||||
{
|
||||
Info<< "Sampling volVectorField " << fieldName << endl << endl;
|
||||
|
||||
forAll(surfaces, surfaceI)
|
||||
{
|
||||
const surface& s = surfaces[surfaceI];
|
||||
|
||||
vectorField values
|
||||
(
|
||||
s.interpolate
|
||||
(
|
||||
fieldName,
|
||||
vectorCache,
|
||||
pInterpPtr,
|
||||
interpolationSchemes
|
||||
)
|
||||
);
|
||||
|
||||
// Collect values from all processors
|
||||
List<vectorField> gatheredValues(Pstream::nProcs());
|
||||
gatheredValues[Pstream::myProcNo()] = values;
|
||||
Pstream::gatherList(gatheredValues);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
vectorField allValues
|
||||
(
|
||||
ListListOps::combine<vectorField>
|
||||
(
|
||||
gatheredValues,
|
||||
accessOp<vectorField>()
|
||||
)
|
||||
);
|
||||
|
||||
// Renumber (point data) to correspond to merged points
|
||||
renumberData
|
||||
(
|
||||
allOldToNewPoints[surfaceI],
|
||||
allPoints[surfaceI].size(),
|
||||
allValues
|
||||
);
|
||||
|
||||
// Write to time directory under sampleSurfaces/
|
||||
vectorFormatter().write
|
||||
(
|
||||
samplePath,
|
||||
runTime.timeName(),
|
||||
s.name(),
|
||||
allPoints[surfaceI],
|
||||
allFaces[surfaceI],
|
||||
fieldName,
|
||||
allValues
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SphericalTensor fields
|
||||
|
||||
else if (sphericalTensorCache.found(fieldName))
|
||||
{
|
||||
Info<< "Sampling volSphericalTensorField "
|
||||
<< fieldName << endl << endl;
|
||||
|
||||
forAll(surfaces, surfaceI)
|
||||
{
|
||||
const surface& s = surfaces[surfaceI];
|
||||
|
||||
sphericalTensorField values
|
||||
(
|
||||
s.interpolate
|
||||
(
|
||||
fieldName,
|
||||
sphericalTensorCache,
|
||||
pInterpPtr,
|
||||
interpolationSchemes
|
||||
)
|
||||
);
|
||||
|
||||
// Collect values from all processors
|
||||
List<sphericalTensorField>
|
||||
gatheredValues(Pstream::nProcs());
|
||||
|
||||
gatheredValues[Pstream::myProcNo()] = values;
|
||||
Pstream::gatherList(gatheredValues);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
sphericalTensorField allValues
|
||||
(
|
||||
ListListOps::combine<sphericalTensorField>
|
||||
(
|
||||
gatheredValues,
|
||||
accessOp<sphericalTensorField>()
|
||||
)
|
||||
);
|
||||
|
||||
// Renumber (point data) to correspond to merged points
|
||||
renumberData
|
||||
(
|
||||
allOldToNewPoints[surfaceI],
|
||||
allPoints[surfaceI].size(),
|
||||
allValues
|
||||
);
|
||||
|
||||
// Write to time directory under sampleSurfaces/
|
||||
sphericalTensorFormatter().write
|
||||
(
|
||||
samplePath,
|
||||
runTime.timeName(),
|
||||
s.name(),
|
||||
allPoints[surfaceI],
|
||||
allFaces[surfaceI],
|
||||
fieldName,
|
||||
allValues
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SymmTensor fields
|
||||
|
||||
else if (symmTensorCache.found(fieldName))
|
||||
{
|
||||
Info<< "Sampling volSymmTensorField "
|
||||
<< fieldName << endl << endl;
|
||||
|
||||
forAll(surfaces, surfaceI)
|
||||
{
|
||||
const surface& s = surfaces[surfaceI];
|
||||
|
||||
symmTensorField values
|
||||
(
|
||||
s.interpolate
|
||||
(
|
||||
fieldName,
|
||||
symmTensorCache,
|
||||
pInterpPtr,
|
||||
interpolationSchemes
|
||||
)
|
||||
);
|
||||
|
||||
// Collect values from all processors
|
||||
List<symmTensorField> gatheredValues(Pstream::nProcs());
|
||||
gatheredValues[Pstream::myProcNo()] = values;
|
||||
Pstream::gatherList(gatheredValues);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
symmTensorField allValues
|
||||
(
|
||||
ListListOps::combine<symmTensorField>
|
||||
(
|
||||
gatheredValues,
|
||||
accessOp<symmTensorField>()
|
||||
)
|
||||
);
|
||||
|
||||
// Renumber (point data) to correspond to merged points
|
||||
renumberData
|
||||
(
|
||||
allOldToNewPoints[surfaceI],
|
||||
allPoints[surfaceI].size(),
|
||||
allValues
|
||||
);
|
||||
|
||||
// Write to time directory under sampleSurfaces/
|
||||
symmTensorFormatter().write
|
||||
(
|
||||
samplePath,
|
||||
runTime.timeName(),
|
||||
s.name(),
|
||||
allPoints[surfaceI],
|
||||
allFaces[surfaceI],
|
||||
fieldName,
|
||||
allValues
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tensor fields
|
||||
|
||||
else if (tensorCache.found(fieldName))
|
||||
{
|
||||
Info<< "Sampling volTensorField " << fieldName << endl << endl;
|
||||
|
||||
forAll(surfaces, surfaceI)
|
||||
{
|
||||
const surface& s = surfaces[surfaceI];
|
||||
|
||||
tensorField values
|
||||
(
|
||||
s.interpolate
|
||||
(
|
||||
fieldName,
|
||||
tensorCache,
|
||||
pInterpPtr,
|
||||
interpolationSchemes
|
||||
)
|
||||
);
|
||||
|
||||
// Collect values from all processors
|
||||
List<tensorField> gatheredValues(Pstream::nProcs());
|
||||
gatheredValues[Pstream::myProcNo()] = values;
|
||||
Pstream::gatherList(gatheredValues);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
tensorField allValues
|
||||
(
|
||||
ListListOps::combine<tensorField>
|
||||
(
|
||||
gatheredValues,
|
||||
accessOp<tensorField>()
|
||||
)
|
||||
);
|
||||
|
||||
// Renumber (point data) to correspond to merged points
|
||||
renumberData
|
||||
(
|
||||
allOldToNewPoints[surfaceI],
|
||||
allPoints[surfaceI].size(),
|
||||
allValues
|
||||
);
|
||||
|
||||
// Write to time directory under sampleSurfaces/
|
||||
tensorFormatter().write
|
||||
(
|
||||
samplePath,
|
||||
runTime.timeName(),
|
||||
s.name(),
|
||||
allPoints[surfaceI],
|
||||
allFaces[surfaceI],
|
||||
fieldName,
|
||||
allValues
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,117 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
|
||||
root "/home/penfold/mattijs/foam/mattijs2.1/run/icoFoam";
|
||||
case "cavity";
|
||||
instance "system";
|
||||
local "";
|
||||
|
||||
class dictionary;
|
||||
object sampleDict;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// Output format. Choice of
|
||||
// foamFile : separate points, faces and values file
|
||||
// dx : DX scalar or vector format
|
||||
// vtk : VTK ascii format
|
||||
// raw : x y z value format for use with e.g. gnuplot 'splot'.
|
||||
// stl : ascii stl. Does not contain values!
|
||||
surfaceFormat vtk;
|
||||
|
||||
|
||||
// interpolationScheme : choice of
|
||||
// cell : use cell-centre value only; constant over cells
|
||||
// cellPoint : use cell-centre and vertex values
|
||||
// cellPointFace : use cell-centre, vertex and face values.
|
||||
// 1] vertex values determined from neighbouring cell-centre values
|
||||
// 2] face values determined using the current face interpolation scheme
|
||||
// for the field (linear, gamma, etc.)
|
||||
interpolationScheme cellPointFace;
|
||||
|
||||
|
||||
// sampling definition: choice of
|
||||
// interpolatedPlane : values on plane defined by point, normal.
|
||||
// One value per vertex using above
|
||||
// interpolationScheme
|
||||
// constantPlane : values on plane defined by point, normal.
|
||||
// One (cell centre) value per triangle
|
||||
// constantPatch : values on patch. One (face centre) value
|
||||
// per triangle.
|
||||
surfaces
|
||||
(
|
||||
constantPlane
|
||||
{
|
||||
name constantPlane;
|
||||
|
||||
basePoint (0.05 0.05 0.005);
|
||||
normalVector (0.1 0.1 1);
|
||||
|
||||
// Optional: whether to leave as faces or triangulate (=default)
|
||||
triangulate false;
|
||||
}
|
||||
|
||||
interpolatedPlane
|
||||
{
|
||||
name interpolatedPlane;
|
||||
|
||||
basePoint (0.05 0.05 0.005);
|
||||
normalVector (0.1 0.1 1);
|
||||
|
||||
triangulate false;
|
||||
}
|
||||
|
||||
|
||||
constantPatch
|
||||
{
|
||||
name movingWall_constant;
|
||||
patchName movingWall;
|
||||
|
||||
triangulate false;
|
||||
}
|
||||
|
||||
interpolatedPatch
|
||||
{
|
||||
name movingWall_interpolated;
|
||||
patchName movingWall;
|
||||
|
||||
triangulate false;
|
||||
}
|
||||
|
||||
constantIsoSurface
|
||||
{
|
||||
name constantIso;
|
||||
field p;
|
||||
value 0;
|
||||
}
|
||||
interpolatedIsoSurface
|
||||
{
|
||||
name someIso;
|
||||
field p;
|
||||
value 0;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// Fields to sample. Note: need to include isoSurface fields.
|
||||
fields
|
||||
(
|
||||
p
|
||||
U
|
||||
);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,325 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "dx.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
#include "faceList.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::dx<Type>::writeDXGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write vertex coordinates
|
||||
|
||||
os << "# The irregular positions" << nl
|
||||
<< "object 1 class array type float rank 1 shape 3 items "
|
||||
<< points.size() << " data follows" << nl;
|
||||
|
||||
forAll(points, pointI)
|
||||
{
|
||||
const point& pt = points[pointI];
|
||||
|
||||
os << float(pt.x()) << ' ' << float(pt.y()) << ' ' << float(pt.z())
|
||||
<< nl;
|
||||
}
|
||||
os << nl;
|
||||
|
||||
// Write triangles
|
||||
|
||||
os << "# The irregular connections (triangles)" << nl
|
||||
<< "object 2 class array type int rank 1 shape 3 items "
|
||||
<< faces.size() << " data follows" << nl;
|
||||
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
const face& f = faces[faceI];
|
||||
|
||||
if (f.size() != 3)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"writeDXGeometry(Ostream&, const pointField&, const faceList&)"
|
||||
) << "Face " << faceI << " vertices " << f
|
||||
<< " is not a triangle."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
os << f[0] << ' ' << f[1] << ' ' << f[2] << nl;
|
||||
}
|
||||
os << "attribute \"element type\" string \"triangles\"" << nl
|
||||
<< "attribute \"ref\" string \"positions\"" << nl << nl;
|
||||
}
|
||||
|
||||
|
||||
// Write scalarField in DX format
|
||||
template<class Type>
|
||||
void Foam::dx<Type>::writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const scalarField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
os << "object 3 class array type float rank 0 items "
|
||||
<< values.size()
|
||||
<< " data follows" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
os << float(values[elemI]) << nl;
|
||||
}
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"positions\""
|
||||
<< nl << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"connections\""
|
||||
<< nl << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write vectorField in DX format
|
||||
template<class Type>
|
||||
void Foam::dx<Type>::writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const vectorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
os << "object 3 class array type float rank 1 shape 3 items "
|
||||
<< values.size()
|
||||
<< " data follows" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
os << float(values[elemI].x()) << ' '
|
||||
<< float(values[elemI].y()) << ' '
|
||||
<< float(values[elemI].z()) << nl;
|
||||
}
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"positions\""
|
||||
<< nl << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"connections\""
|
||||
<< nl << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write sphericalTensorField in DX format
|
||||
template<class Type>
|
||||
void Foam::dx<Type>::writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const sphericalTensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
os << "object 3 class array type float rank 0 items "
|
||||
<< values.size()
|
||||
<< " data follows" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
os << float(values[elemI][0]) << nl;
|
||||
}
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"positions\""
|
||||
<< nl << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"connections\""
|
||||
<< nl << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write symmTensorField in DX format
|
||||
template<class Type>
|
||||
void Foam::dx<Type>::writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const symmTensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
os << "object 3 class array type float rank 2 shape 3 items "
|
||||
<< values.size()
|
||||
<< " data follows" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const symmTensor& t = values[elemI];
|
||||
|
||||
os << float(t.xx()) << ' ' << float(t.xy()) << ' ' << float(t.xz())
|
||||
<< float(t.xy()) << ' ' << float(t.yy()) << ' ' << float(t.yz())
|
||||
<< float(t.xz()) << ' ' << float(t.yz()) << ' ' << float(t.zz())
|
||||
<< nl;
|
||||
}
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"positions\""
|
||||
<< nl << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"connections\""
|
||||
<< nl << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write tensorField in DX format
|
||||
template<class Type>
|
||||
void Foam::dx<Type>::writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const tensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
os << "object 3 class array type float rank 2 shape 3 items "
|
||||
<< values.size()
|
||||
<< " data follows" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const tensor& t = values[elemI];
|
||||
|
||||
os << float(t.xx()) << ' ' << float(t.xy()) << ' ' << float(t.xz())
|
||||
<< float(t.yx()) << ' ' << float(t.yy()) << ' ' << float(t.yz())
|
||||
<< float(t.zx()) << ' ' << float(t.zy()) << ' ' << float(t.zz())
|
||||
<< nl;
|
||||
}
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"positions\""
|
||||
<< nl << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << nl << "attribute \"dep\" string \"connections\""
|
||||
<< nl << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write trailer in DX format
|
||||
template<class Type>
|
||||
void Foam::dx<Type>::writeDXTrailer(Ostream& os) const
|
||||
{
|
||||
os << "# the field, with three components: \"positions\","
|
||||
<< " \"connections\", and \"data\"" << nl
|
||||
<< "object \"irregular positions irregular "
|
||||
<< "connections\" class field"
|
||||
<< nl
|
||||
<< "component \"positions\" value 1" << nl
|
||||
<< "component \"connections\" value 2" << nl
|
||||
<< "component \"data\" value 3" << nl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::dx<Type>::dx()
|
||||
:
|
||||
surfaceWriter<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::dx<Type>::~dx()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::dx<Type>::write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values
|
||||
) const
|
||||
{
|
||||
fileName surfaceDir(samplePath/timeDir);
|
||||
|
||||
if (!exists(surfaceDir))
|
||||
{
|
||||
mkDir(surfaceDir);
|
||||
}
|
||||
|
||||
fileName planeFName(surfaceDir/fieldName + '_' + surfaceName + ".dx");
|
||||
|
||||
Info<< "Writing field " << fieldName << " to " << planeFName << endl;
|
||||
|
||||
OFstream dxFile(planeFName);
|
||||
|
||||
writeDXGeometry(points, faces, dxFile);
|
||||
|
||||
writeDXData(points, values, dxFile);
|
||||
|
||||
writeDXTrailer(dxFile);
|
||||
|
||||
dxFile << "end" << nl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,150 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::dx
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
dx.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef dx_H
|
||||
#define dx_H
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class dx Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class dx
|
||||
:
|
||||
public surfaceWriter<Type>
|
||||
{
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void writeDXGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const scalarField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const vectorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const sphericalTensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const symmTensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeDXData
|
||||
(
|
||||
const pointField& points,
|
||||
const tensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeDXTrailer(Ostream& os) const;
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("dx");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
dx();
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~dx();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
|
||||
//- Writes single surface to file.
|
||||
virtual void write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "dx.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,43 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "dxWriters.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeWriters(dx);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,63 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::dxWriters
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
dxWriters.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef dxWriters_H
|
||||
#define dxWriters_H
|
||||
|
||||
#include "dx.H"
|
||||
#include "surfaceWriters.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef dx<scalar> dxScalarWriter;
|
||||
typedef dx<vector> dxVectorWriter;
|
||||
typedef dx<sphericalTensor> dxSphericalTensorWriter;
|
||||
typedef dx<symmTensor> dxSymmTensorWriter;
|
||||
typedef dx<tensor> dxTensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,99 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "foamFile.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
#include "faceList.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::foamFile<Type>::foamFile()
|
||||
:
|
||||
surfaceWriter<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::foamFile<Type>::~foamFile()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::foamFile<Type>::write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values
|
||||
) const
|
||||
{
|
||||
fileName planeFName(samplePath/timeDir/surfaceName);
|
||||
|
||||
if (!exists(planeFName))
|
||||
{
|
||||
mkDir(planeFName);
|
||||
}
|
||||
|
||||
Info<< "Writing field " << fieldName << " to " << planeFName << endl;
|
||||
|
||||
// Points
|
||||
OFstream pointsFile(planeFName/"points");
|
||||
|
||||
pointsFile << points;
|
||||
|
||||
// Faces
|
||||
OFstream facesFile(planeFName/"faces");
|
||||
|
||||
facesFile << faces;
|
||||
|
||||
// Values to separate directory (e.g. "scalarField/p")
|
||||
|
||||
fileName foamName(pTraits<Type>::typeName);
|
||||
|
||||
fileName valuesDir(planeFName / (foamName + Field<Type>::typeName));
|
||||
|
||||
if (!exists(valuesDir))
|
||||
{
|
||||
mkDir(valuesDir);
|
||||
}
|
||||
|
||||
OFstream valuesFile(valuesDir/fieldName);
|
||||
|
||||
valuesFile << values;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,104 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::foamFile
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
foamFile.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef foamFile_H
|
||||
#define foamFile_H
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class foamFile Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class foamFile
|
||||
:
|
||||
public surfaceWriter<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("foamFile");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
foamFile();
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~foamFile();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
|
||||
//- Writes single surface to file.
|
||||
virtual void write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "foamFile.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,43 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "foamFileWriters.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeWriters(foamFile);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,63 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::foamFileWriters
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
foamFileWriters.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef foamFileWriters_H
|
||||
#define foamFileWriters_H
|
||||
|
||||
#include "foamFile.H"
|
||||
#include "surfaceWriters.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef foamFile<scalar> foamFileScalarWriter;
|
||||
typedef foamFile<vector> foamFileVectorWriter;
|
||||
typedef foamFile<sphericalTensor> foamFileSphericalTensorWriter;
|
||||
typedef foamFile<symmTensor> foamFileSymmTensorWriter;
|
||||
typedef foamFile<tensor> foamFileTensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,359 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "raw.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
#include "faceList.H"
|
||||
#include "OSspecific.H"
|
||||
#include "IOmanip.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::writeGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const label& pointI,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
const point& pt = points[pointI];
|
||||
|
||||
os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << ' ';
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::writeGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const label& faceI,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
const point& ct = faces[faceI].centre(points);
|
||||
|
||||
os << ct.x() << ' ' << ct.y() << ' ' << ct.z() << ' ';
|
||||
}
|
||||
|
||||
// Write scalarField in raw format
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const scalarField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// header
|
||||
os << "# " << fieldName;
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << " POINT_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << " FACE_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
os << "# x y z " << fieldName
|
||||
<< endl;
|
||||
|
||||
// Write data
|
||||
forAll(values, elemI)
|
||||
{
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
writeGeometry(points, elemI, os);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeGeometry(points, faces, elemI, os);
|
||||
}
|
||||
os << values[elemI] << endl;
|
||||
}
|
||||
os << nl;
|
||||
}
|
||||
|
||||
|
||||
// Write vectorField in raw format
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const vectorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// header
|
||||
os << "# " << fieldName;
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << " POINT_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << " FACE_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
os << "# x y z "
|
||||
<< fieldName << "_x "
|
||||
<< fieldName << "_y "
|
||||
<< fieldName << "_z "
|
||||
<< endl;
|
||||
|
||||
// Write data
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const vector& v = values[elemI];
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
writeGeometry(points, elemI, os);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeGeometry(points, faces, elemI, os);
|
||||
}
|
||||
|
||||
os << v[0] << ' ' << v[1] << ' ' << v[2] << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write sphericalTensorField in raw format
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const sphericalTensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// header
|
||||
os << "# " << fieldName;
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << " POINT_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << " FACE_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
os << "# ii ";
|
||||
os << fieldName << "_ii" << endl;
|
||||
|
||||
// Write data
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const sphericalTensor& v = values[elemI];
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
writeGeometry(points, elemI, os);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeGeometry(points, faces, elemI, os);
|
||||
}
|
||||
|
||||
os << v[0] << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write symmTensorField in raw format
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const symmTensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// header
|
||||
os << "# " << fieldName;
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << " POINT_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << " FACE_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
os << "# xx xy xz yy yz ";
|
||||
for(int i=0; i<6; i++)
|
||||
{
|
||||
os << fieldName << "_" << i << " ";
|
||||
}
|
||||
os << endl;
|
||||
|
||||
// Write data
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const symmTensor& v = values[elemI];
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
writeGeometry(points, elemI, os);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeGeometry(points, faces, elemI, os);
|
||||
}
|
||||
|
||||
os << v[0] << ' ' << v[1] << ' ' << v[2]
|
||||
<< v[3] << ' ' << v[4] << ' ' << v[5]
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write tensorField in raw format
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const tensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// header
|
||||
os << "# " << fieldName;
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << " POINT_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << " FACE_DATA " << values.size()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
os << "# xx xy xz yx yy yz zx zy zz";
|
||||
for(int i=0; i<9; i++)
|
||||
{
|
||||
os << fieldName << "_" << i << " ";
|
||||
}
|
||||
os << endl;
|
||||
|
||||
// Write data
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const tensor& v = values[elemI];
|
||||
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
writeGeometry(points, elemI, os);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeGeometry(points, faces, elemI, os);
|
||||
}
|
||||
|
||||
os << v[0] << ' ' << v[1] << ' ' << v[2]
|
||||
<< v[3] << ' ' << v[4] << ' ' << v[5]
|
||||
<< v[6] << ' ' << v[7] << ' ' << v[8] << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::raw<Type>::raw()
|
||||
:
|
||||
surfaceWriter<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::raw<Type>::~raw()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::raw<Type>::write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values
|
||||
) const
|
||||
{
|
||||
fileName surfaceDir(samplePath/timeDir);
|
||||
|
||||
if (!exists(surfaceDir))
|
||||
{
|
||||
mkDir(surfaceDir);
|
||||
}
|
||||
|
||||
fileName planeFName(surfaceDir/fieldName + '_' + surfaceName + ".raw");
|
||||
|
||||
Info<< "Writing field " << fieldName << " to " << planeFName << endl;
|
||||
|
||||
OFstream rawFile(planeFName);
|
||||
|
||||
writeData(fieldName, points, faces, values, rawFile);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,166 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::raw
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
raw.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef raw_H
|
||||
#define raw_H
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class raw Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class raw
|
||||
:
|
||||
public surfaceWriter<Type>
|
||||
{
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void writeGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const label& pointI,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const label& faceI,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const scalarField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const vectorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const sphericalTensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const symmTensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const tensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("raw");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
raw();
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~raw();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
|
||||
//- Writes single surface to file.
|
||||
virtual void write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "raw.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,43 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rawWriters.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeWriters(raw);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,63 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::rawWriters
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
rawWriters.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef rawWriters_H
|
||||
#define rawWriters_H
|
||||
|
||||
#include "raw.H"
|
||||
#include "surfaceWriters.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef raw<scalar> rawScalarWriter;
|
||||
typedef raw<vector> rawVectorWriter;
|
||||
typedef raw<sphericalTensor> rawSphericalTensorWriter;
|
||||
typedef raw<symmTensor> rawSymmTensorWriter;
|
||||
typedef raw<tensor> rawTensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,112 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "stl.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
#include "faceList.H"
|
||||
#include "OSspecific.H"
|
||||
#include "triSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::stl<Type>::stl()
|
||||
:
|
||||
surfaceWriter<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::stl<Type>::~stl()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::stl<Type>::write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values
|
||||
) const
|
||||
{
|
||||
fileName surfaceDir(samplePath/timeDir);
|
||||
|
||||
if (!exists(surfaceDir))
|
||||
{
|
||||
mkDir(surfaceDir);
|
||||
}
|
||||
|
||||
fileName planeFName(surfaceDir/fieldName + '_' + surfaceName + ".stl");
|
||||
|
||||
Info<< "Writing field " << fieldName << " to " << planeFName << endl;
|
||||
|
||||
|
||||
// Convert faces to triangles.
|
||||
DynamicList<labelledTri> tris(faces.size());
|
||||
|
||||
forAll(faces, i)
|
||||
{
|
||||
const face& f = faces[i];
|
||||
|
||||
faceList triFaces(f.nTriangles(points));
|
||||
label nTris = 0;
|
||||
f.triangles(points, nTris, triFaces);
|
||||
|
||||
forAll(triFaces, triI)
|
||||
{
|
||||
const face& tri = triFaces[triI];
|
||||
tris.append(labelledTri(tri[0], tri[1], tri[2], 0));
|
||||
}
|
||||
}
|
||||
|
||||
triSurface
|
||||
(
|
||||
tris.shrink(),
|
||||
geometricSurfacePatchList
|
||||
(
|
||||
1,
|
||||
geometricSurfacePatch
|
||||
(
|
||||
"patch", // geometricType
|
||||
string::validate<word>(fieldName), // fieldName
|
||||
0 // index
|
||||
)
|
||||
),
|
||||
points
|
||||
).write(planeFName);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,104 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::stl
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
stl.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef stl_H
|
||||
#define stl_H
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class stl Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class stl
|
||||
:
|
||||
public surfaceWriter<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("stl");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
stl();
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~stl();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
|
||||
//- Writes single surface to file.
|
||||
virtual void write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "stl.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,43 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "stlWriters.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeWriters(stl);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,63 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::stlWriters
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
stlWriters.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef stlWriters_H
|
||||
#define stlWriters_H
|
||||
|
||||
#include "stl.H"
|
||||
#include "surfaceWriters.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef stl<scalar> stlScalarWriter;
|
||||
typedef stl<vector> stlVectorWriter;
|
||||
typedef stl<sphericalTensor> stlSphericalTensorWriter;
|
||||
typedef stl<symmTensor> stlSymmTensorWriter;
|
||||
typedef stl<tensor> stlTensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,78 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
#include "HashTable.H"
|
||||
#include "word.H"
|
||||
#include "fileName.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
template<class Type>
|
||||
autoPtr<surfaceWriter<Type> > surfaceWriter<Type>::New(const word& writeType)
|
||||
{
|
||||
typename wordConstructorTable::iterator cstrIter =
|
||||
wordConstructorTablePtr_
|
||||
->find(writeType);
|
||||
|
||||
if (cstrIter == wordConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"surfaceWriter::New(const word&)"
|
||||
) << "Unknown write type " << writeType
|
||||
<< endl << endl
|
||||
<< "Valid write types : " << endl
|
||||
<< wordConstructorTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<surfaceWriter<Type> >(cstrIter()());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
surfaceWriter<Type>::surfaceWriter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
surfaceWriter<Type>::~surfaceWriter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,158 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::surfaceWriter
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
surfaceWriter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfaceWriter_H
|
||||
#define surfaceWriter_H
|
||||
|
||||
#include "Field.H"
|
||||
#include "typeInfo.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "autoPtr.H"
|
||||
#include "pointField.H"
|
||||
#include "faceList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfaceWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class surfaceWriter
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("surfaceWriter");
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
surfaceWriter,
|
||||
word,
|
||||
(),
|
||||
()
|
||||
);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected surfaceWriter
|
||||
static autoPtr<surfaceWriter> New(const word& writeFormat);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
surfaceWriter();
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~surfaceWriter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Writes single surface to file. Either one value per vertex or
|
||||
// one value per face (detected by values.size()==faces.size())
|
||||
virtual void write
|
||||
(
|
||||
const fileName& samplePath, // <root>/<case>/sampleSurfaces
|
||||
const fileName& timeDir, // time directory
|
||||
const fileName& surfaceName, // name of surface
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName, // name of field
|
||||
const Field<Type>& values
|
||||
) const = 0;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "surfaceWriter.C"
|
||||
#endif
|
||||
|
||||
// Only used internally
|
||||
#define makeTypeWritersTypeName(type) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(type, 0);
|
||||
|
||||
// Used externally sometimes
|
||||
#define makeWritersTypeName(typeWriter) \
|
||||
\
|
||||
makeTypeWritersTypeName(typeWriter##ScalarWriter); \
|
||||
makeTypeWritersTypeName(typeWriter##VectorWriter); \
|
||||
makeTypeWritersTypeName(typeWriter##SphericalTensorWriter); \
|
||||
makeTypeWritersTypeName(typeWriter##SymmTensorWriter); \
|
||||
makeTypeWritersTypeName(typeWriter##TensorWriter);
|
||||
|
||||
// Define type info for single template instantiation (e.g. vector)
|
||||
#define makeWriterTypes(WriterType, type) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(type, 0); \
|
||||
\
|
||||
addToRunTimeSelectionTable \
|
||||
( \
|
||||
WriterType, type, word \
|
||||
);
|
||||
|
||||
|
||||
// Define type info info for scalar, vector etc. instantiations
|
||||
#define makeWriters(typeWriter) \
|
||||
\
|
||||
makeWriterTypes(scalarWriter, typeWriter##ScalarWriter); \
|
||||
makeWriterTypes(vectorWriter, typeWriter##VectorWriter); \
|
||||
makeWriterTypes(sphericalTensorWriter, typeWriter##SphericalTensorWriter); \
|
||||
makeWriterTypes(symmTensorWriter, typeWriter##SymmTensorWriter);\
|
||||
makeWriterTypes(tensorWriter, typeWriter##TensorWriter);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,55 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfaceWriters.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineNamedTemplateTypeNameAndDebug(scalarWriter, 0);
|
||||
defineTemplateRunTimeSelectionTable(scalarWriter, word);
|
||||
|
||||
defineNamedTemplateTypeNameAndDebug(vectorWriter, 0);
|
||||
defineTemplateRunTimeSelectionTable(vectorWriter, word);
|
||||
|
||||
defineNamedTemplateTypeNameAndDebug(sphericalTensorWriter, 0);
|
||||
defineTemplateRunTimeSelectionTable(sphericalTensorWriter, word);
|
||||
|
||||
defineNamedTemplateTypeNameAndDebug(symmTensorWriter, 0);
|
||||
defineTemplateRunTimeSelectionTable(symmTensorWriter, word);
|
||||
|
||||
defineNamedTemplateTypeNameAndDebug(tensorWriter, 0);
|
||||
defineTemplateRunTimeSelectionTable(tensorWriter, word);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,59 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::surfaceWriter
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfaceWriters_H
|
||||
#define surfaceWriters_H
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef surfaceWriter<scalar> scalarWriter;
|
||||
typedef surfaceWriter<vector> vectorWriter;
|
||||
typedef surfaceWriter<sphericalTensor> sphericalTensorWriter;
|
||||
typedef surfaceWriter<symmTensor> symmTensorWriter;
|
||||
typedef surfaceWriter<tensor> tensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,330 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtk.H"
|
||||
#include "fileName.H"
|
||||
#include "OFstream.H"
|
||||
#include "faceList.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtk<Type>::writeGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write vertex coordinates
|
||||
|
||||
os
|
||||
<< "# vtk DataFile Version 2.0" << nl
|
||||
<< "sampleSurface" << nl
|
||||
<< "ASCII" << nl
|
||||
<< "DATASET POLYDATA" << nl;
|
||||
|
||||
os << "POINTS " << points.size() << " float" << nl;
|
||||
|
||||
forAll(points, pointI)
|
||||
{
|
||||
const point& pt = points[pointI];
|
||||
|
||||
os << float(pt.x()) << ' ' << float(pt.y()) << ' ' << float(pt.z())
|
||||
<< nl;
|
||||
}
|
||||
os << endl;
|
||||
|
||||
|
||||
// Write triangles
|
||||
|
||||
label nFaceVerts = 0;
|
||||
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
const face& f = faces[faceI];
|
||||
|
||||
nFaceVerts += f.size() + 1;
|
||||
}
|
||||
|
||||
os << "POLYGONS " << faces.size() << ' ' << nFaceVerts << nl;
|
||||
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
const face& f = faces[faceI];
|
||||
|
||||
os << f.size();
|
||||
|
||||
forAll(f, fp)
|
||||
{
|
||||
os << ' ' << f[fp];
|
||||
}
|
||||
os << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write scalarField in vtk format
|
||||
template<class Type>
|
||||
void Foam::vtk<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const scalarField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << "POINT_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "CELL_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
|
||||
os << fieldName << " 1 " << values.size() << " float" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
os << float(values[elemI]);
|
||||
|
||||
if (elemI > 0 && (elemI%10) == 0)
|
||||
{
|
||||
os << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
os << nl;
|
||||
}
|
||||
|
||||
|
||||
// Write vectorField in vtk format
|
||||
template<class Type>
|
||||
void Foam::vtk<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const vectorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << "POINT_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "CELL_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
|
||||
os << fieldName << " 3 " << values.size() << " float" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const vector& v = values[elemI];
|
||||
|
||||
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2]) << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write sphericalTensorField in vtk format
|
||||
template<class Type>
|
||||
void Foam::vtk<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const sphericalTensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << "POINT_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "CELL_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
|
||||
os << fieldName << " 1 " << values.size() << " float" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const sphericalTensor& v = values[elemI];
|
||||
|
||||
os << float(v[0])
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write symmTensorField in vtk format
|
||||
template<class Type>
|
||||
void Foam::vtk<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const symmTensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << "POINT_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "CELL_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
|
||||
os << fieldName << " 6 " << values.size() << " float" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const symmTensor& v = values[elemI];
|
||||
|
||||
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2])
|
||||
<< float(v[3]) << ' ' << float(v[4]) << ' ' << float(v[5])
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write tensorField in vtk format
|
||||
template<class Type>
|
||||
void Foam::vtk<Type>::writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const tensorField& values,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
// Write data
|
||||
if (values.size() == points.size())
|
||||
{
|
||||
os << "POINT_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "CELL_DATA " << values.size()
|
||||
<< nl
|
||||
<< "FIELD attributes 1" << nl;
|
||||
}
|
||||
|
||||
os << fieldName << " 9 " << values.size() << " float" << nl;
|
||||
|
||||
forAll(values, elemI)
|
||||
{
|
||||
const tensor& v = values[elemI];
|
||||
|
||||
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2])
|
||||
<< float(v[3]) << ' ' << float(v[4]) << ' ' << float(v[5])
|
||||
<< float(v[6]) << ' ' << float(v[7]) << ' ' << float(v[8])
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
template<class Type>
|
||||
Foam::vtk<Type>::vtk()
|
||||
:
|
||||
surfaceWriter<Type>()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::vtk<Type>::~vtk()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::vtk<Type>::write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values
|
||||
) const
|
||||
{
|
||||
fileName surfaceDir(samplePath/timeDir);
|
||||
|
||||
if (!exists(surfaceDir))
|
||||
{
|
||||
mkDir(surfaceDir);
|
||||
}
|
||||
|
||||
fileName planeFName(surfaceDir/fieldName + '_' + surfaceName + ".vtk");
|
||||
|
||||
Info<< "Writing field " << fieldName << " to " << planeFName << endl;
|
||||
|
||||
OFstream vtkFile(planeFName);
|
||||
|
||||
writeGeometry(points, faces, vtkFile);
|
||||
|
||||
writeData(fieldName, points, values, vtkFile);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,153 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::vtk
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
vtk.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtk_H
|
||||
#define vtk_H
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class vtk Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class vtk
|
||||
:
|
||||
public surfaceWriter<Type>
|
||||
{
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void writeGeometry
|
||||
(
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const scalarField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const vectorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const sphericalTensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const symmTensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
void writeData
|
||||
(
|
||||
const fileName& fieldName,
|
||||
const pointField& points,
|
||||
const tensorField& values,
|
||||
Ostream& os
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("vtk");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
vtk();
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~vtk();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
|
||||
//- Writes single surface to file.
|
||||
virtual void write
|
||||
(
|
||||
const fileName& samplePath,
|
||||
const fileName& timeDir,
|
||||
const fileName& surfaceName,
|
||||
const pointField& points,
|
||||
const faceList& faces,
|
||||
const fileName& fieldName,
|
||||
const Field<Type>& values
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "vtk.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,43 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkWriters.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makeWriters(vtk);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,63 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
Foam::vtkWriters
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
vtkWriters.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vtkWriters_H
|
||||
#define vtkWriters_H
|
||||
|
||||
#include "vtk.H"
|
||||
#include "surfaceWriters.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef vtk<scalar> vtkScalarWriter;
|
||||
typedef vtk<vector> vtkVectorWriter;
|
||||
typedef vtk<sphericalTensor> vtkSphericalTensorWriter;
|
||||
typedef vtk<symmTensor> vtkSymmTensorWriter;
|
||||
typedef vtk<tensor> vtkTensorWriter;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,271 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "constantIsoSurface.H"
|
||||
#include "meshSearch.H"
|
||||
#include "polyMesh.H"
|
||||
#include "interpolation.H"
|
||||
#include "dictionary.H"
|
||||
#include "meshCutSurface.H"
|
||||
#include "cellDecompIsoSurfaceCuts.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(constantIsoSurface, 0);
|
||||
|
||||
addToRunTimeSelectionTable(surface, constantIsoSurface, word);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type> > Foam::constantIsoSurface::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<Type>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField =
|
||||
*cache[fieldName];
|
||||
|
||||
tmp<Field<Type> > tresult(new Field<Type>(faces().size()));
|
||||
Field<Type>& result = tresult();
|
||||
|
||||
forAll(result, faceI)
|
||||
{
|
||||
result[faceI] = vField[cellLabels_[faceI]];
|
||||
}
|
||||
|
||||
return tresult;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::constantIsoSurface::constantIsoSurface
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& isoFieldName,
|
||||
const scalar isoVal
|
||||
)
|
||||
:
|
||||
surface(mesh, searchEngine, name),
|
||||
isoFieldName_(isoFieldName),
|
||||
isoVal_(isoVal),
|
||||
points_(0),
|
||||
faces_(0),
|
||||
cellLabels_(0)
|
||||
{}
|
||||
|
||||
|
||||
Foam::constantIsoSurface::constantIsoSurface
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
surface(mesh, searchEngine, dict),
|
||||
isoFieldName_(dict.lookup("field")),
|
||||
isoVal_(readScalar(dict.lookup("value"))),
|
||||
points_(0),
|
||||
faces_(0),
|
||||
cellLabels_(0)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::constantIsoSurface::~constantIsoSurface()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::constantIsoSurface::correct
|
||||
(
|
||||
const bool meshChanged,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes,
|
||||
const fieldsCache<scalar>& scalarCache
|
||||
)
|
||||
{
|
||||
if (!scalarCache.found(isoFieldName_))
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"constantIsoSurface::correct(const bool meshChanged,"
|
||||
"const volPointInterpolation&, const fieldsCache<scalar>&"
|
||||
", const fieldsCache<vector>&, const fieldsCache<tensor>&)"
|
||||
) << "Field " << isoFieldName_ << " not loaded." << endl
|
||||
<< "It has to be one of the sampled fields"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
const volScalarField& vField = *scalarCache[isoFieldName_];
|
||||
|
||||
const pointScalarField& pField =
|
||||
scalarCache.pointField(isoFieldName_, pInterp);
|
||||
|
||||
// Create smooth volField.
|
||||
volScalarField smoothVolField(vField);
|
||||
|
||||
const labelListList& cellPoints = vField.mesh().cellPoints();
|
||||
|
||||
forAll(cellPoints, cellI)
|
||||
{
|
||||
const labelList& cPoints = cellPoints[cellI];
|
||||
|
||||
scalar sum = 0;
|
||||
|
||||
forAll(cPoints, i)
|
||||
{
|
||||
sum += pField[cPoints[i]];
|
||||
}
|
||||
smoothVolField[cellI] = sum / cPoints.size();
|
||||
}
|
||||
|
||||
|
||||
cellDecompIsoSurfaceCuts isoSurfaceCuts
|
||||
(
|
||||
smoothVolField,
|
||||
pField,
|
||||
isoVal_,
|
||||
-0.1
|
||||
);
|
||||
|
||||
meshCutSurface isoSurf(isoSurfaceCuts);
|
||||
|
||||
points_ = isoSurf.points();
|
||||
|
||||
// Convert triangles into faces
|
||||
faces_.setSize(isoSurf.size());
|
||||
cellLabels_.setSize(isoSurf.size());
|
||||
|
||||
forAll(isoSurf, triI)
|
||||
{
|
||||
face& f = faces_[triI];
|
||||
const labelledTri& t = isoSurf[triI];
|
||||
|
||||
f.setSize(3);
|
||||
f[0] = t[0];
|
||||
f[1] = t[1];
|
||||
f[2] = t[2];
|
||||
|
||||
cellLabels_[triI] = t.region();
|
||||
}
|
||||
|
||||
Pout<< "Created " << name() << " :"
|
||||
<< " isoValue:" << isoVal_
|
||||
<< " field:" << isoFieldName_
|
||||
<< " faces:" << faces_.size()
|
||||
<< " points:" << points_.size() << endl;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::constantIsoSurface::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<scalar>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<scalar>(fieldName, cache, pInterp, interpolationSchemes);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::constantIsoSurface::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<vector>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<vector>(fieldName, cache, pInterp, interpolationSchemes);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::constantIsoSurface::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<sphericalTensor>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<sphericalTensor>
|
||||
(
|
||||
fieldName,
|
||||
cache,
|
||||
pInterp,
|
||||
interpolationSchemes
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::constantIsoSurface::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<symmTensor>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<symmTensor>
|
||||
(
|
||||
fieldName,
|
||||
cache,
|
||||
pInterp,
|
||||
interpolationSchemes
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::constantIsoSurface::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<tensor>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<tensor>(fieldName, cache, pInterp, interpolationSchemes);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,199 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::constantIsoSurface
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
constantIsoSurface.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef constantIsoSurface_H
|
||||
#define constantIsoSurface_H
|
||||
|
||||
#include "surface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
//class meshSearch;
|
||||
class dictionary;
|
||||
class plane;
|
||||
class volPointInterpolation;
|
||||
template<class Type> class fieldsCache;
|
||||
class cellDecompIsoSurfaceCuts;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class constantIsoSurface Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class constantIsoSurface
|
||||
:
|
||||
public surface
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of field to use to construct isosurface
|
||||
const word isoFieldName_;
|
||||
|
||||
//- Iso surface value
|
||||
const scalar isoVal_;
|
||||
|
||||
//- Generated points
|
||||
mutable pointField points_;
|
||||
|
||||
//- Generated triangles
|
||||
mutable faceList faces_;
|
||||
|
||||
//- Labels into original cells
|
||||
mutable labelList cellLabels_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<Type> > interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<Type>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("constantIsoSurface");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
constantIsoSurface
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& isoFieldName,
|
||||
const scalar isoVal
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
constantIsoSurface
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~constantIsoSurface();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Points of surface
|
||||
virtual const pointField& points() const
|
||||
{
|
||||
return points_;
|
||||
};
|
||||
|
||||
//- Faces of surface
|
||||
virtual const faceList& faces() const
|
||||
{
|
||||
return faces_;
|
||||
}
|
||||
|
||||
//- Correct for mesh movement and/or field changes
|
||||
virtual void correct
|
||||
(
|
||||
const bool meshChanged,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes,
|
||||
const fieldsCache<scalar>&
|
||||
);
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<scalar>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<vector>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<sphericalTensor>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<symmTensor>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<tensor>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,282 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "constantPatch.H"
|
||||
#include "meshSearch.H"
|
||||
#include "polyMesh.H"
|
||||
#include "interpolation.H"
|
||||
#include "dictionary.H"
|
||||
#include "polyPatch.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(constantPatch, 0);
|
||||
|
||||
addToRunTimeSelectionTable(surface, constantPatch, word);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::constantPatch::makeTriangles()
|
||||
{
|
||||
if (patchIndex_ != -1)
|
||||
{
|
||||
const polyPatch& patch = mesh().boundaryMesh()[patchIndex_];
|
||||
|
||||
// Count triangles
|
||||
label nTris = 0;
|
||||
|
||||
const faceList& localFaces = patch.localFaces();
|
||||
|
||||
forAll(localFaces, patchFaceI)
|
||||
{
|
||||
const face& f = localFaces[patchFaceI];
|
||||
|
||||
nTris += f.nTriangles(patch.localPoints());
|
||||
}
|
||||
|
||||
// Triangulation is done using all localPoints
|
||||
points_ = patch.localPoints();
|
||||
|
||||
faces_.setSize(nTris);
|
||||
patchFaceLabels_.setSize(nTris);
|
||||
|
||||
label triI = 0;
|
||||
label oldTriI = 0;
|
||||
|
||||
forAll(localFaces, patchFaceI)
|
||||
{
|
||||
const face& f = localFaces[patchFaceI];
|
||||
|
||||
f.triangles(patch.localPoints(), triI, faces_);
|
||||
|
||||
for(label i = oldTriI; i < triI; i++)
|
||||
{
|
||||
patchFaceLabels_[i] = patchFaceI;
|
||||
}
|
||||
|
||||
oldTriI = triI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::constantPatch::copyFaces()
|
||||
{
|
||||
if (patchIndex_ != -1)
|
||||
{
|
||||
const polyPatch& patch = mesh().boundaryMesh()[patchIndex_];
|
||||
|
||||
points_ = patch.localPoints();
|
||||
faces_ = patch.localFaces();
|
||||
patchFaceLabels_.setSize(faces_.size());
|
||||
forAll(patchFaceLabels_, i)
|
||||
{
|
||||
patchFaceLabels_[i] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::constantPatch::createGeometry()
|
||||
{
|
||||
if (triangulate_)
|
||||
{
|
||||
makeTriangles();
|
||||
}
|
||||
else
|
||||
{
|
||||
copyFaces();
|
||||
}
|
||||
|
||||
Pout<< "Created " << name() << " :"
|
||||
<< " patch:" << patchName_
|
||||
<< " faces:" << faces_.size()
|
||||
<< " points:" << points_.size() << endl;
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
Foam::tmp<Foam::Field<Type> > Foam::constantPatch::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<Type>& cache
|
||||
) const
|
||||
{
|
||||
// One value per face
|
||||
tmp<Field<Type> > tvalues(new Field<Type>(patchFaceLabels_.size()));
|
||||
Field<Type>& values = tvalues();
|
||||
|
||||
if (patchIndex_ != -1)
|
||||
{
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField =
|
||||
*cache[fieldName];
|
||||
|
||||
const Field<Type>& bField = vField.boundaryField()[patchIndex_];
|
||||
|
||||
forAll(patchFaceLabels_, elemI)
|
||||
{
|
||||
values[elemI] = bField[patchFaceLabels_[elemI]];
|
||||
}
|
||||
}
|
||||
|
||||
return tvalues;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::constantPatch::constantPatch
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& patchName,
|
||||
const bool triangulate
|
||||
)
|
||||
:
|
||||
surface(mesh, searchEngine, name),
|
||||
patchName_(patchName),
|
||||
patchIndex_(mesh.boundaryMesh().findPatchID(patchName_)),
|
||||
triangulate_(triangulate),
|
||||
points_(0),
|
||||
faces_(0),
|
||||
patchFaceLabels_(0)
|
||||
{
|
||||
createGeometry();
|
||||
}
|
||||
|
||||
|
||||
Foam::constantPatch::constantPatch
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
surface(mesh, searchEngine, dict),
|
||||
patchName_(dict.lookup("patchName")),
|
||||
patchIndex_(mesh.boundaryMesh().findPatchID(patchName_)),
|
||||
triangulate_(getBool(dict, "triangulate", true)),
|
||||
points_(0),
|
||||
faces_(0),
|
||||
patchFaceLabels_(0)
|
||||
{
|
||||
createGeometry();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::constantPatch::~constantPatch()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::constantPatch::correct
|
||||
(
|
||||
const bool meshChanged,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes,
|
||||
const fieldsCache<scalar>& scalarCache
|
||||
)
|
||||
{
|
||||
if (meshChanged)
|
||||
{
|
||||
createGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::constantPatch::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<scalar>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<scalar>(fieldName, cache);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::constantPatch::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<vector>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<vector>(fieldName, cache);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::constantPatch::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<sphericalTensor>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<sphericalTensor>(fieldName, cache);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::constantPatch::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<symmTensor>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<symmTensor>(fieldName, cache);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::constantPatch::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<tensor>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<tensor>(fieldName, cache);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,223 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::constantPatch
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
constantPatch.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef constantPatch_H
|
||||
#define constantPatch_H
|
||||
|
||||
#include "surface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
//class meshSearch;
|
||||
class dictionary;
|
||||
class plane;
|
||||
class volPointInterpolation;
|
||||
template<class Type> class fieldsCache;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class constantPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class constantPatch
|
||||
:
|
||||
public surface
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of patch
|
||||
const word patchName_;
|
||||
|
||||
//- Index of patch in boundaryMesh
|
||||
const label patchIndex_;
|
||||
|
||||
//- Make triangles or keep faces
|
||||
const bool triangulate_;
|
||||
|
||||
//- Zero size or copy of patch.localPoints()
|
||||
pointField points_;
|
||||
|
||||
//- Generated triangles
|
||||
faceList faces_;
|
||||
|
||||
//- Original patch face labels
|
||||
labelList patchFaceLabels_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Triangulate patch
|
||||
void makeTriangles();
|
||||
|
||||
void copyFaces();
|
||||
|
||||
//- Do all to construct geometry.
|
||||
void createGeometry();
|
||||
|
||||
//- Interpolate field onto faces
|
||||
template <class Type>
|
||||
tmp<Field<Type> > interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<Type>&
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("constantPatch");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
constantPatch
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& patchName,
|
||||
const bool triangulate = true
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
constantPatch
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~constantPatch();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
const word patchName() const
|
||||
{
|
||||
return patchName_;
|
||||
}
|
||||
|
||||
label patchIndex() const
|
||||
{
|
||||
return patchIndex_;
|
||||
}
|
||||
|
||||
const labelList& patchFaceLabels() const
|
||||
{
|
||||
return patchFaceLabels_;
|
||||
}
|
||||
|
||||
//- Points of surface
|
||||
virtual const pointField& points() const
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
|
||||
//- Faces of surface
|
||||
virtual const faceList& faces() const
|
||||
{
|
||||
return faces_;
|
||||
}
|
||||
|
||||
//- Correct for mesh movement and/or field changes
|
||||
virtual void correct
|
||||
(
|
||||
const bool meshChanged,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes,
|
||||
const fieldsCache<scalar>&
|
||||
);
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<scalar>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<vector>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<sphericalTensor>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<symmTensor>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<tensor>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,263 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "constantPlane.H"
|
||||
#include "meshSearch.H"
|
||||
#include "polyMesh.H"
|
||||
#include "interpolation.H"
|
||||
#include "dictionary.H"
|
||||
#include "plane.H"
|
||||
#include "cuttingPlane.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(constantPlane, 0);
|
||||
|
||||
addToRunTimeSelectionTable(surface, constantPlane, word);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::constantPlane::makeTriangles(const cuttingPlane& cut)
|
||||
{
|
||||
// Count triangles
|
||||
label nTris = 0;
|
||||
forAll(cut.faces(), cutFaceI)
|
||||
{
|
||||
const face& f = cut.faces()[cutFaceI];
|
||||
|
||||
nTris += f.nTriangles(cut.points());
|
||||
}
|
||||
|
||||
// Triangulation uses all points from cut
|
||||
points_ = cut.points();
|
||||
|
||||
faces_.setSize(nTris);
|
||||
meshCells_.setSize(nTris);
|
||||
|
||||
label triI = 0;
|
||||
label oldTriI = 0;
|
||||
|
||||
forAll(cut.faces(), cutFaceI)
|
||||
{
|
||||
const face& f = cut.faces()[cutFaceI];
|
||||
|
||||
f.triangles(cut.points(), triI, faces_);
|
||||
|
||||
for(label i = oldTriI; i < triI; i++)
|
||||
{
|
||||
meshCells_[i] = cut.cells()[cutFaceI];
|
||||
}
|
||||
|
||||
oldTriI = triI;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::constantPlane::copyFaces(const cuttingPlane& cut)
|
||||
{
|
||||
points_ = cut.points();
|
||||
faces_ = cut.faces();
|
||||
meshCells_ = cut.cells();
|
||||
}
|
||||
|
||||
|
||||
void Foam::constantPlane::createGeometry()
|
||||
{
|
||||
cuttingPlane plane(mesh(), planeDesc_);
|
||||
|
||||
if (triangulate_)
|
||||
{
|
||||
makeTriangles(plane);
|
||||
}
|
||||
else
|
||||
{
|
||||
copyFaces(plane);
|
||||
}
|
||||
|
||||
Pout<< "Created " << name() << " :"
|
||||
<< " base:" << planeDesc_.refPoint()
|
||||
<< " normal:" << planeDesc_.normal()
|
||||
<< " faces:" << faces_.size()
|
||||
<< " points:" << points_.size() << endl;
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
Foam::tmp<Foam::Field<Type> > Foam::constantPlane::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<Type>& cache
|
||||
) const
|
||||
{
|
||||
// One value per face
|
||||
tmp<Field<Type> > tvalues(new Field<Type>(meshCells_.size()));
|
||||
Field<Type>& values = tvalues();
|
||||
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field =
|
||||
*cache[fieldName];
|
||||
|
||||
forAll(meshCells_, elemI)
|
||||
{
|
||||
values[elemI] = field[meshCells_[elemI]];
|
||||
}
|
||||
|
||||
return tvalues;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::constantPlane::constantPlane
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const plane& planeDesc,
|
||||
const bool triangulate
|
||||
)
|
||||
:
|
||||
surface(mesh, searchEngine, name),
|
||||
planeDesc_(planeDesc),
|
||||
triangulate_(triangulate),
|
||||
points_(0),
|
||||
faces_(0),
|
||||
meshCells_(0)
|
||||
{
|
||||
createGeometry();
|
||||
}
|
||||
|
||||
|
||||
Foam::constantPlane::constantPlane
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
surface(mesh, searchEngine, dict),
|
||||
planeDesc_(dict.lookup("basePoint"), dict.lookup("normalVector")),
|
||||
triangulate_(getBool(dict, "triangulate", true)),
|
||||
points_(0),
|
||||
faces_(0),
|
||||
meshCells_(0)
|
||||
{
|
||||
createGeometry();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::constantPlane::~constantPlane()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::constantPlane::correct
|
||||
(
|
||||
const bool meshChanged,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes,
|
||||
const fieldsCache<scalar>& scalarCache
|
||||
)
|
||||
{
|
||||
if (meshChanged)
|
||||
{
|
||||
// Only change of mesh changes plane.
|
||||
createGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::constantPlane::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<scalar>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<scalar>(fieldName, cache);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::constantPlane::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<vector>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<vector>(fieldName, cache);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::constantPlane::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<sphericalTensor>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<sphericalTensor>(fieldName, cache);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::constantPlane::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<symmTensor>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<symmTensor>(fieldName, cache);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::constantPlane::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<tensor>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<tensor>(fieldName, cache);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,219 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::constantPlane
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
constantPlane.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef constantPlane_H
|
||||
#define constantPlane_H
|
||||
|
||||
#include "surface.H"
|
||||
#include "cuttingPlane.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class polyMesh;
|
||||
class meshSearch;
|
||||
class dictionary;
|
||||
class plane;
|
||||
class volPointInterpolation;
|
||||
template<class Type> class fieldsCache;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class constantPlane Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class constantPlane
|
||||
:
|
||||
public surface
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Cutting plane description
|
||||
const plane planeDesc_;
|
||||
|
||||
//- Make triangles or keep faces
|
||||
const bool triangulate_;
|
||||
|
||||
//- Generated points
|
||||
pointField points_;
|
||||
|
||||
//- Generated faces
|
||||
faceList faces_;
|
||||
|
||||
//- Fro every face original cell in mesh
|
||||
labelList meshCells_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Cut & triangulate
|
||||
void makeTriangles(const cuttingPlane&);
|
||||
|
||||
//- Copy cut; do not triangulate
|
||||
void copyFaces(const cuttingPlane&);
|
||||
|
||||
//- Do all to create geometry. Cut&triangulate if nessecary
|
||||
void createGeometry();
|
||||
|
||||
//- Interpolate field onto faces
|
||||
template <class Type>
|
||||
tmp<Field<Type> > interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<Type>& cache
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("constantPlane");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
constantPlane
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const plane& planeDesc,
|
||||
const bool triangulate = true
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
constantPlane
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~constantPlane();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
const plane& planeDesc() const
|
||||
{
|
||||
return planeDesc_;
|
||||
}
|
||||
|
||||
const labelList& meshCells() const
|
||||
{
|
||||
return meshCells_;
|
||||
}
|
||||
|
||||
//- Points of surface
|
||||
virtual const pointField& points() const
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
|
||||
//- Faces of surface
|
||||
virtual const faceList& faces() const
|
||||
{
|
||||
return faces_;
|
||||
}
|
||||
|
||||
//- Correct for mesh movement and/or field changes
|
||||
virtual void correct
|
||||
(
|
||||
const bool meshChanged,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes,
|
||||
const fieldsCache<scalar>&
|
||||
);
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<scalar>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<vector>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<sphericalTensor>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<symmTensor>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<tensor>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,281 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "interpolatedIsoSurface.H"
|
||||
#include "meshSearch.H"
|
||||
#include "polyMesh.H"
|
||||
#include "interpolation.H"
|
||||
#include "dictionary.H"
|
||||
#include "meshCutSurface.H"
|
||||
#include "cellDecompIsoSurfaceCuts.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(interpolatedIsoSurface, 0);
|
||||
|
||||
addToRunTimeSelectionTable(surface, interpolatedIsoSurface, word);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type> > Foam::interpolatedIsoSurface::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<Type>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField =
|
||||
*cache[fieldName];
|
||||
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& pField =
|
||||
cache.pointField(fieldName, pInterp);
|
||||
|
||||
return meshCutSurface::interpolate(isoSurfCuts(), vField, pField);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::interpolatedIsoSurface::interpolatedIsoSurface
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& isoFieldName,
|
||||
const scalar isoVal
|
||||
)
|
||||
:
|
||||
surface(mesh, searchEngine, name),
|
||||
isoFieldName_(isoFieldName),
|
||||
isoVal_(isoVal),
|
||||
points_(0),
|
||||
faces_(0),
|
||||
isoSurfCutsPtr_(NULL)
|
||||
{}
|
||||
|
||||
|
||||
Foam::interpolatedIsoSurface::interpolatedIsoSurface
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
surface(mesh, searchEngine, dict),
|
||||
isoFieldName_(dict.lookup("field")),
|
||||
isoVal_(readScalar(dict.lookup("value"))),
|
||||
points_(0),
|
||||
faces_(0),
|
||||
isoSurfCutsPtr_(NULL)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::interpolatedIsoSurface::~interpolatedIsoSurface()
|
||||
{
|
||||
if (isoSurfCutsPtr_)
|
||||
{
|
||||
delete isoSurfCutsPtr_;
|
||||
isoSurfCutsPtr_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::cellDecompIsoSurfaceCuts&
|
||||
Foam::interpolatedIsoSurface::isoSurfCuts() const
|
||||
{
|
||||
if (!isoSurfCutsPtr_)
|
||||
{
|
||||
FatalErrorIn("interpolatedIsoSurface::isoSurfCuts()")
|
||||
<< "No interpolatedIsoSurfaceCuts allocated" << abort(FatalError);
|
||||
}
|
||||
return *isoSurfCutsPtr_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::interpolatedIsoSurface::correct
|
||||
(
|
||||
const bool meshChanged,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes,
|
||||
const fieldsCache<scalar>& scalarCache
|
||||
)
|
||||
{
|
||||
if (!scalarCache.found(isoFieldName_))
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"interpolatedIsoSurface::correct(const bool meshChanged,"
|
||||
"const volPointInterpolation&, const fieldsCache<scalar>&"
|
||||
", const fieldsCache<vector>&, const fieldsCache<tensor>&)"
|
||||
) << "Field " << isoFieldName_ << " not loaded." << endl
|
||||
<< "It has to be one of the sampled fields"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
const volScalarField& vField = *scalarCache[isoFieldName_];
|
||||
|
||||
const pointScalarField& pField =
|
||||
scalarCache.pointField(isoFieldName_, pInterp);
|
||||
|
||||
if (isoSurfCutsPtr_)
|
||||
{
|
||||
delete isoSurfCutsPtr_;
|
||||
}
|
||||
|
||||
isoSurfCutsPtr_ = new cellDecompIsoSurfaceCuts
|
||||
(
|
||||
vField,
|
||||
pField,
|
||||
isoVal_,
|
||||
-0.1
|
||||
);
|
||||
|
||||
meshCutSurface isoSurf(isoSurfCuts());
|
||||
|
||||
points_ = isoSurf.points();
|
||||
|
||||
// Convert triangles into faces
|
||||
faces_.setSize(isoSurf.size());
|
||||
|
||||
forAll(isoSurf, triI)
|
||||
{
|
||||
face& f = faces_[triI];
|
||||
const labelledTri& t = isoSurf[triI];
|
||||
|
||||
f.setSize(3);
|
||||
f[0] = t[0];
|
||||
f[1] = t[1];
|
||||
f[2] = t[2];
|
||||
}
|
||||
|
||||
Pout<< "Created " << name() << " :"
|
||||
<< " isoValue:" << isoVal_
|
||||
<< " field:" << isoFieldName_
|
||||
<< " faces:" << faces_.size()
|
||||
<< " points:" << points_.size() << endl;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::interpolatedIsoSurface::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<scalar>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
if (fieldName == isoFieldName_)
|
||||
{
|
||||
// Same field as isoSurface was based on -> single value.
|
||||
return tmp<scalarField>(new scalarField(points_.size(), isoVal_));
|
||||
}
|
||||
else
|
||||
{
|
||||
return interpolate<scalar>
|
||||
(
|
||||
fieldName,
|
||||
cache,
|
||||
pInterp,
|
||||
interpolationSchemes
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::interpolatedIsoSurface::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<vector>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<vector>(fieldName, cache, pInterp, interpolationSchemes);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::interpolatedIsoSurface::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<sphericalTensor>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<sphericalTensor>
|
||||
(
|
||||
fieldName,
|
||||
cache,
|
||||
pInterp,
|
||||
interpolationSchemes
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::interpolatedIsoSurface::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<symmTensor>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<symmTensor>
|
||||
(
|
||||
fieldName,
|
||||
cache,
|
||||
pInterp,
|
||||
interpolationSchemes
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::interpolatedIsoSurface::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<tensor>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<tensor>(fieldName, cache, pInterp, interpolationSchemes);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,203 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::interpolatedIsoSurface
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
interpolatedIsoSurface.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef interpolatedIsoSurface_H
|
||||
#define interpolatedIsoSurface_H
|
||||
|
||||
#include "surface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
//class meshSearch;
|
||||
class dictionary;
|
||||
class plane;
|
||||
class volPointInterpolation;
|
||||
template<class Type> class fieldsCache;
|
||||
class cellDecompIsoSurfaceCuts;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class interpolatedIsoSurface Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class interpolatedIsoSurface
|
||||
:
|
||||
public surface
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of field to use to construct isosurface
|
||||
const word isoFieldName_;
|
||||
|
||||
//- Iso surface value
|
||||
const scalar isoVal_;
|
||||
|
||||
//- Generated points
|
||||
mutable pointField points_;
|
||||
|
||||
//- Generated triangles
|
||||
mutable faceList faces_;
|
||||
|
||||
//- Iso surface edge descriptors
|
||||
const cellDecompIsoSurfaceCuts* isoSurfCutsPtr_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
template<class Type>
|
||||
tmp<Field<Type> > interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<Type>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("interpolatedIsoSurface");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
interpolatedIsoSurface
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& isoFieldName,
|
||||
const scalar isoVal
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
interpolatedIsoSurface
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~interpolatedIsoSurface();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Access isoSurface edge cuts
|
||||
const cellDecompIsoSurfaceCuts& isoSurfCuts() const;
|
||||
|
||||
//- Points of surface
|
||||
virtual const pointField& points() const
|
||||
{
|
||||
return points_;
|
||||
};
|
||||
|
||||
//- Faces of surface
|
||||
virtual const faceList& faces() const
|
||||
{
|
||||
return faces_;
|
||||
}
|
||||
|
||||
//- Correct for mesh movement and/or field changes. Differs from
|
||||
// constantIsoSurface one since meshCuts are stored for use in
|
||||
// interpolation later on
|
||||
virtual void correct
|
||||
(
|
||||
const bool meshChanged,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes,
|
||||
const fieldsCache<scalar>&
|
||||
);
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<scalar>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<vector>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<sphericalTensor>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<symmTensor>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<tensor>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,211 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "interpolatedPatch.H"
|
||||
#include "meshSearch.H"
|
||||
#include "polyMesh.H"
|
||||
#include "interpolation.H"
|
||||
#include "dictionary.H"
|
||||
#include "polyPatch.H"
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(interpolatedPatch, 0);
|
||||
|
||||
addToRunTimeSelectionTable(surface, interpolatedPatch, word);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
Foam::tmp<Foam::Field<Type> > Foam::interpolatedPatch::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<Type>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
// One value per vertex
|
||||
tmp<Field<Type> > tvalues(new Field<Type>(points().size()));
|
||||
Field<Type>& values = tvalues();
|
||||
|
||||
// Get interpolator from cache
|
||||
const interpolation<Type>& interpolator =
|
||||
cache.interpolator(fieldName, pInterp, interpolationSchemes);
|
||||
|
||||
if (patchIndex() != -1)
|
||||
{
|
||||
const polyPatch& patch = mesh().boundaryMesh()[patchIndex()];
|
||||
const labelList& own = mesh().faceOwner();
|
||||
|
||||
boolList pointDone(points().size(), false);
|
||||
|
||||
forAll(faces(), cutFaceI)
|
||||
{
|
||||
const face& f = faces()[cutFaceI];
|
||||
|
||||
forAll(f, faceVertI)
|
||||
{
|
||||
label pointI = f[faceVertI];
|
||||
|
||||
if (!pointDone[pointI])
|
||||
{
|
||||
label faceI = patchFaceLabels()[cutFaceI] + patch.start();
|
||||
|
||||
label cellI = own[faceI];
|
||||
|
||||
values[pointI] =
|
||||
interpolator.interpolate
|
||||
(
|
||||
points()[pointI],
|
||||
cellI,
|
||||
faceI
|
||||
);
|
||||
pointDone[pointI] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tvalues;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::interpolatedPatch::interpolatedPatch
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& patchName,
|
||||
const bool triangulate
|
||||
)
|
||||
:
|
||||
constantPatch(mesh, searchEngine, name, patchName, triangulate)
|
||||
{}
|
||||
|
||||
|
||||
Foam::interpolatedPatch::interpolatedPatch
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
constantPatch(mesh, searchEngine, dict)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::interpolatedPatch::~interpolatedPatch()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::interpolatedPatch::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<scalar>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<scalar>(fieldName, cache, pInterp, interpolationSchemes);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::interpolatedPatch::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<vector>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<vector>(fieldName, cache, pInterp, interpolationSchemes);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::sphericalTensorField> Foam::interpolatedPatch::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<sphericalTensor>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<sphericalTensor>
|
||||
(
|
||||
fieldName,
|
||||
cache,
|
||||
pInterp,
|
||||
interpolationSchemes
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::symmTensorField> Foam::interpolatedPatch::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<symmTensor>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<symmTensor>
|
||||
(
|
||||
fieldName,
|
||||
cache,
|
||||
pInterp,
|
||||
interpolationSchemes
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::tensorField> Foam::interpolatedPatch::interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<tensor>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const
|
||||
{
|
||||
return interpolate<tensor>(fieldName, cache, pInterp, interpolationSchemes);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,163 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::interpolatedPatch
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
interpolatedPatch.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef interpolatedPatch_H
|
||||
#define interpolatedPatch_H
|
||||
|
||||
#include "surface.H"
|
||||
#include "constantPatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class meshSearch;
|
||||
class dictionary;
|
||||
class plane;
|
||||
class volPointInterpolation;
|
||||
template<class Type> class fieldsCache;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class interpolatedPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class interpolatedPatch
|
||||
:
|
||||
public constantPatch
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Interpolate field onto faces
|
||||
template <class Type>
|
||||
tmp<Field<Type> > interpolate
|
||||
(
|
||||
const word& fieldName,
|
||||
const fieldsCache<Type>& cache,
|
||||
const volPointInterpolation& pInterp,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("interpolatedPatch");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
interpolatedPatch
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const word& name,
|
||||
const word& patchName,
|
||||
const bool triangulate = true
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
interpolatedPatch
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~interpolatedPatch();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- correct() implemented by constantPatch::correct()
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<scalarField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<scalar>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<vectorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<vector>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<sphericalTensorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<sphericalTensor>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<symmTensorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<symmTensor>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
|
||||
//- interpolate field to surface
|
||||
virtual tmp<tensorField> interpolate
|
||||
(
|
||||
const word&,
|
||||
const fieldsCache<tensor>&,
|
||||
const volPointInterpolation&,
|
||||
const dictionary& interpolationSchemes
|
||||
) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user