sampling reworking
- write geometry file if no fields would be sampled - write geometry file only once for obj, stl formats and use MeshedSurfaceProxy for writing
This commit is contained in:
parent
fadf428091
commit
ba771d1901
@ -81,7 +81,7 @@ public:
|
|||||||
const coordSet&,
|
const coordSet&,
|
||||||
const wordList&,
|
const wordList&,
|
||||||
const List<const Field<Type>*>&,
|
const List<const Field<Type>*>&,
|
||||||
Ostream& os
|
Ostream&
|
||||||
) const;
|
) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ License
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
makeSetWriters(gnuplotSetWriter)
|
makeSetWriters(gnuplotSetWriter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
@ -54,7 +54,7 @@ class jplotSetWriter
|
|||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Write header
|
//- Write header
|
||||||
Ostream& writeHeader(Ostream& os) const;
|
Ostream& writeHeader(Ostream&) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ public:
|
|||||||
const coordSet&,
|
const coordSet&,
|
||||||
const wordList&,
|
const wordList&,
|
||||||
const List<const Field<Type>*>&,
|
const List<const Field<Type>*>&,
|
||||||
Ostream& os
|
Ostream&
|
||||||
) const;
|
) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ License
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
makeSetWriters(jplotSetWriter)
|
makeSetWriters(jplotSetWriter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
@ -81,7 +81,7 @@ public:
|
|||||||
const coordSet&,
|
const coordSet&,
|
||||||
const wordList&,
|
const wordList&,
|
||||||
const List<const Field<Type>*>&,
|
const List<const Field<Type>*>&,
|
||||||
Ostream& os
|
Ostream&
|
||||||
) const;
|
) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ License
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
makeSetWriters(rawSetWriter)
|
makeSetWriters(rawSetWriter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
@ -91,22 +91,12 @@ protected:
|
|||||||
//- Generates filename from coordSet and sampled fields
|
//- Generates filename from coordSet and sampled fields
|
||||||
fileName getBaseName(const coordSet&, const wordList&) const;
|
fileName getBaseName(const coordSet&, const wordList&) const;
|
||||||
|
|
||||||
void writeCoord
|
void writeCoord(const coordSet&, const label sampleI, Ostream&) const;
|
||||||
(
|
|
||||||
const coordSet& samples,
|
|
||||||
const label sampleI,
|
|
||||||
Ostream& os
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Writes single-column ascii write. Column 1 is coordSet coordinate,
|
//- Writes single-column ascii write. Column 1 is coordSet coordinate,
|
||||||
// columns 2 is the value. Uses write() function
|
// columns 2 is the value. Uses write() function
|
||||||
// to write coordinate in correct format.
|
// to write coordinate in correct format.
|
||||||
void writeTable
|
void writeTable(const coordSet&, const List<Type>&, Ostream&) const;
|
||||||
(
|
|
||||||
const coordSet&,
|
|
||||||
const List<Type>&,
|
|
||||||
Ostream& os
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Writes multi-column ascii write. Column 1 is coordSet coordinate,
|
//- Writes multi-column ascii write. Column 1 is coordSet coordinate,
|
||||||
// columns 2..n are the values. Uses write() function
|
// columns 2..n are the values. Uses write() function
|
||||||
@ -139,10 +129,7 @@ public:
|
|||||||
// Selectors
|
// Selectors
|
||||||
|
|
||||||
//- Return a reference to the selected writer
|
//- Return a reference to the selected writer
|
||||||
static autoPtr<writer> New
|
static autoPtr<writer> New(const word& writeFormat);
|
||||||
(
|
|
||||||
const word& writeFormat
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
@ -165,8 +152,8 @@ public:
|
|||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
//- General entry point for writing.
|
//- General entry point for writing.
|
||||||
// The data is organized in a set of point with one or
|
// The data is organized in a set of point with one or more values
|
||||||
// more values per point
|
// per point
|
||||||
virtual void write
|
virtual void write
|
||||||
(
|
(
|
||||||
const coordSet&,
|
const coordSet&,
|
||||||
@ -179,7 +166,7 @@ public:
|
|||||||
virtual Ostream& write(const scalar, Ostream&) const;
|
virtual Ostream& write(const scalar, Ostream&) const;
|
||||||
|
|
||||||
template<class VSType>
|
template<class VSType>
|
||||||
Ostream& writeVS(const VSType& value, Ostream& os) const;
|
Ostream& writeVS(const VSType&, Ostream&) const;
|
||||||
|
|
||||||
//- Write vector. Tab separated ascii
|
//- Write vector. Tab separated ascii
|
||||||
virtual Ostream& write(const vector&, Ostream&) const;
|
virtual Ostream& write(const vector&, Ostream&) const;
|
||||||
|
@ -40,27 +40,27 @@ SourceFiles
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Only used internally
|
// Only used internally
|
||||||
#define makeTypeSetWritersTypeName(typeWriter, dataType) \
|
#define makeTypeSetWritersTypeName(typeWriter, dataType) \
|
||||||
\
|
\
|
||||||
defineNamedTemplateTypeNameAndDebug(typeWriter<dataType >, 0);
|
defineNamedTemplateTypeNameAndDebug(typeWriter< dataType >, 0)
|
||||||
|
|
||||||
// Sometimes used externally
|
// Sometimes used externally
|
||||||
#define makeSetWritersTypeName(typeWriter) \
|
#define makeSetWritersTypeName(typeWriter) \
|
||||||
\
|
\
|
||||||
makeTypeSetWritersTypeName(typeWriter, scalar); \
|
makeTypeSetWritersTypeName(typeWriter, scalar); \
|
||||||
makeTypeSetWritersTypeName(typeWriter, vector); \
|
makeTypeSetWritersTypeName(typeWriter, vector); \
|
||||||
makeTypeSetWritersTypeName(typeWriter, sphericalTensor); \
|
makeTypeSetWritersTypeName(typeWriter, sphericalTensor); \
|
||||||
makeTypeSetWritersTypeName(typeWriter, symmTensor); \
|
makeTypeSetWritersTypeName(typeWriter, symmTensor); \
|
||||||
makeTypeSetWritersTypeName(typeWriter, tensor);
|
makeTypeSetWritersTypeName(typeWriter, tensor)
|
||||||
|
|
||||||
// Define type info for single dataType template instantiation (eg, vector)
|
// Define type info for single dataType template instantiation (eg, vector)
|
||||||
#define makeSetWriterType(typeWriter, dataType) \
|
#define makeSetWriterType(typeWriter, dataType) \
|
||||||
\
|
\
|
||||||
defineNamedTemplateTypeNameAndDebug(typeWriter<dataType >, 0); \
|
defineNamedTemplateTypeNameAndDebug(typeWriter< dataType >, 0); \
|
||||||
addTemplatedToRunTimeSelectionTable \
|
addTemplatedToRunTimeSelectionTable \
|
||||||
( \
|
( \
|
||||||
writer, typeWriter, dataType, word \
|
writer, typeWriter, dataType, word \
|
||||||
);
|
)
|
||||||
|
|
||||||
|
|
||||||
// Define type info for scalar, vector etc. instantiations
|
// Define type info for scalar, vector etc. instantiations
|
||||||
@ -70,7 +70,7 @@ SourceFiles
|
|||||||
makeSetWriterType(typeWriter, vector); \
|
makeSetWriterType(typeWriter, vector); \
|
||||||
makeSetWriterType(typeWriter, sphericalTensor); \
|
makeSetWriterType(typeWriter, sphericalTensor); \
|
||||||
makeSetWriterType(typeWriter, symmTensor); \
|
makeSetWriterType(typeWriter, symmTensor); \
|
||||||
makeSetWriterType(typeWriter, tensor);
|
makeSetWriterType(typeWriter, tensor)
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
@ -81,7 +81,7 @@ public:
|
|||||||
const coordSet&,
|
const coordSet&,
|
||||||
const wordList&,
|
const wordList&,
|
||||||
const List<const Field<Type>*>&,
|
const List<const Field<Type>*>&,
|
||||||
Ostream& os
|
Ostream&
|
||||||
) const;
|
) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ License
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
makeSetWriters(xmgraceSetWriter)
|
makeSetWriters(xmgraceSetWriter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
@ -70,18 +70,27 @@ Foam::scalar Foam::sampledSurfaces::mergeTol_(1e-10);
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::sampledSurfaces::checkFieldTypes()
|
Foam::label Foam::sampledSurfaces::classifyFieldTypes()
|
||||||
{
|
{
|
||||||
wordList fieldTypes(fieldNames_.size());
|
label nFields = 0;
|
||||||
|
|
||||||
// check files for a particular time
|
scalarFields_.clear();
|
||||||
if (loadFromFiles_)
|
vectorFields_.clear();
|
||||||
|
sphericalTensorFields_.clear();
|
||||||
|
symmTensorFields_.clear();
|
||||||
|
tensorFields_.clear();
|
||||||
|
|
||||||
|
forAll(fieldNames_, fieldI)
|
||||||
{
|
{
|
||||||
forAll(fieldNames_, fieldI)
|
const word& fieldName = fieldNames_[fieldI];
|
||||||
|
word fieldType = "";
|
||||||
|
|
||||||
|
// check files for a particular time
|
||||||
|
if (loadFromFiles_)
|
||||||
{
|
{
|
||||||
IOobject io
|
IOobject io
|
||||||
(
|
(
|
||||||
fieldNames_[fieldI],
|
fieldName,
|
||||||
mesh_.time().timeName(),
|
mesh_.time().timeName(),
|
||||||
mesh_,
|
mesh_,
|
||||||
IOobject::MUST_READ,
|
IOobject::MUST_READ,
|
||||||
@ -91,69 +100,96 @@ bool Foam::sampledSurfaces::checkFieldTypes()
|
|||||||
|
|
||||||
if (io.headerOk())
|
if (io.headerOk())
|
||||||
{
|
{
|
||||||
fieldTypes[fieldI] = io.headerClassName();
|
fieldType = io.headerClassName();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fieldTypes[fieldI] = "(notFound)";
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
|
||||||
{
|
|
||||||
// check objectRegistry
|
|
||||||
forAll(fieldNames_, fieldI)
|
|
||||||
{
|
{
|
||||||
objectRegistry::const_iterator iter =
|
// check objectRegistry
|
||||||
mesh_.find(fieldNames_[fieldI]);
|
objectRegistry::const_iterator iter = mesh_.find(fieldName);
|
||||||
|
|
||||||
if (iter != mesh_.objectRegistry::end())
|
if (iter != mesh_.objectRegistry::end())
|
||||||
{
|
{
|
||||||
fieldTypes[fieldI] = iter()->type();
|
fieldType = iter()->type();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fieldTypes[fieldI] = "(notFound)";
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (fieldType == volScalarField::typeName)
|
||||||
|
{
|
||||||
|
scalarFields_.append(fieldName);
|
||||||
|
nFields++;
|
||||||
|
}
|
||||||
|
else if (fieldType == volVectorField::typeName)
|
||||||
|
{
|
||||||
|
vectorFields_.append(fieldName);
|
||||||
|
nFields++;
|
||||||
|
}
|
||||||
|
else if (fieldType == volSphericalTensorField::typeName)
|
||||||
|
{
|
||||||
|
sphericalTensorFields_.append(fieldName);
|
||||||
|
nFields++;
|
||||||
|
}
|
||||||
|
else if (fieldType == volSymmTensorField::typeName)
|
||||||
|
{
|
||||||
|
symmTensorFields_.append(fieldName);
|
||||||
|
nFields++;
|
||||||
|
}
|
||||||
|
else if (fieldType == volTensorField::typeName)
|
||||||
|
{
|
||||||
|
tensorFields_.append(fieldName);
|
||||||
|
nFields++;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nFields;
|
||||||
|
}
|
||||||
|
|
||||||
label nFields = 0;
|
|
||||||
|
|
||||||
// classify fieldTypes
|
void Foam::sampledSurfaces::writeGeometry() const
|
||||||
nFields += grep(scalarFields_, fieldTypes);
|
{
|
||||||
nFields += grep(vectorFields_, fieldTypes);
|
// Write to time directory under outputPath_
|
||||||
nFields += grep(sphericalTensorFields_, fieldTypes);
|
// skip surface without faces (eg, a failed cut-plane)
|
||||||
nFields += grep(symmTensorFields_, fieldTypes);
|
|
||||||
nFields += grep(tensorFields_, fieldTypes);
|
|
||||||
|
|
||||||
if (Pstream::master())
|
const fileName outputDir = outputPath_/mesh_.time().timeName();
|
||||||
|
|
||||||
|
forAll(*this, surfI)
|
||||||
{
|
{
|
||||||
if (debug)
|
const sampledSurface& s = operator[](surfI);
|
||||||
{
|
|
||||||
Pout<< "timeName = " << mesh_.time().timeName() << nl
|
|
||||||
<< "scalarFields " << scalarFields_ << nl
|
|
||||||
<< "vectorFields " << vectorFields_ << nl
|
|
||||||
<< "sphTensorFields " << sphericalTensorFields_ << nl
|
|
||||||
<< "symTensorFields " << symmTensorFields_ <<nl
|
|
||||||
<< "tensorFields " << tensorFields_ <<nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nFields > 0)
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
if (debug)
|
if (Pstream::master() && mergeList_[surfI].faces.size())
|
||||||
{
|
{
|
||||||
Pout<< "Creating directory "
|
genericFormatter_->write
|
||||||
<< outputPath_/mesh_.time().timeName()
|
(
|
||||||
<< nl << endl;
|
outputDir,
|
||||||
|
s.name(),
|
||||||
|
mergeList_[surfI].points,
|
||||||
|
mergeList_[surfI].faces
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
mkDir(outputPath_/mesh_.time().timeName());
|
else if (s.faces().size())
|
||||||
|
{
|
||||||
|
genericFormatter_->write
|
||||||
|
(
|
||||||
|
outputDir,
|
||||||
|
s.name(),
|
||||||
|
s.points(),
|
||||||
|
s.faces()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nFields > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -176,6 +212,7 @@ Foam::sampledSurfaces::sampledSurfaces
|
|||||||
interpolationScheme_(word::null),
|
interpolationScheme_(word::null),
|
||||||
writeFormat_(word::null),
|
writeFormat_(word::null),
|
||||||
mergeList_(),
|
mergeList_(),
|
||||||
|
genericFormatter_(NULL),
|
||||||
scalarFields_(),
|
scalarFields_(),
|
||||||
vectorFields_(),
|
vectorFields_(),
|
||||||
sphericalTensorFields_(),
|
sphericalTensorFields_(),
|
||||||
@ -223,11 +260,39 @@ void Foam::sampledSurfaces::end()
|
|||||||
|
|
||||||
void Foam::sampledSurfaces::write()
|
void Foam::sampledSurfaces::write()
|
||||||
{
|
{
|
||||||
if (size() && checkFieldTypes())
|
if (size())
|
||||||
{
|
{
|
||||||
// finalize surfaces, merge points etc.
|
// finalize surfaces, merge points etc.
|
||||||
update();
|
update();
|
||||||
|
|
||||||
|
const label nFields = classifyFieldTypes();
|
||||||
|
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "timeName = " << mesh_.time().timeName() << nl
|
||||||
|
<< "scalarFields " << scalarFields_ << nl
|
||||||
|
<< "vectorFields " << vectorFields_ << nl
|
||||||
|
<< "sphTensorFields " << sphericalTensorFields_ << nl
|
||||||
|
<< "symTensorFields " << symmTensorFields_ <<nl
|
||||||
|
<< "tensorFields " << tensorFields_ <<nl;
|
||||||
|
|
||||||
|
Pout<< "Creating directory "
|
||||||
|
<< outputPath_/mesh_.time().timeName() << nl << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
mkDir(outputPath_/mesh_.time().timeName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// write geometry first if required, or when no fields would otherwise
|
||||||
|
// be written
|
||||||
|
if (nFields == 0 || genericFormatter_->separateFiles())
|
||||||
|
{
|
||||||
|
writeGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
sampleAndWrite(scalarFields_);
|
sampleAndWrite(scalarFields_);
|
||||||
sampleAndWrite(vectorFields_);
|
sampleAndWrite(vectorFields_);
|
||||||
sampleAndWrite(sphericalTensorFields_);
|
sampleAndWrite(sphericalTensorFields_);
|
||||||
@ -241,6 +306,14 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
fieldNames_ = wordList(dict.lookup("fields"));
|
fieldNames_ = wordList(dict.lookup("fields"));
|
||||||
|
|
||||||
|
const label nFields = fieldNames_.size();
|
||||||
|
|
||||||
|
scalarFields_.reset(nFields);
|
||||||
|
vectorFields_.reset(nFields);
|
||||||
|
sphericalTensorFields_.reset(nFields);
|
||||||
|
symmTensorFields_.reset(nFields);
|
||||||
|
tensorFields_.reset(nFields);
|
||||||
|
|
||||||
interpolationScheme_ = dict.lookupOrDefault<word>
|
interpolationScheme_ = dict.lookupOrDefault<word>
|
||||||
(
|
(
|
||||||
"interpolationScheme",
|
"interpolationScheme",
|
||||||
@ -252,6 +325,11 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
|
|||||||
"null"
|
"null"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// define the generic (geometry) writer
|
||||||
|
genericFormatter_ = surfaceWriter<bool>::New(writeFormat_);
|
||||||
|
|
||||||
|
|
||||||
PtrList<sampledSurface> newList
|
PtrList<sampledSurface> newList
|
||||||
(
|
(
|
||||||
dict.lookup("surfaces"),
|
dict.lookup("surfaces"),
|
||||||
|
@ -64,24 +64,24 @@ class sampledSurfaces
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
class fieldGroup
|
class fieldGroup
|
||||||
:
|
:
|
||||||
public wordList
|
public DynamicList<word>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Surface formatter
|
//- Surface formatter
|
||||||
autoPtr<surfaceWriter<Type> > formatter;
|
autoPtr< surfaceWriter<Type> > formatter;
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
fieldGroup()
|
fieldGroup()
|
||||||
:
|
:
|
||||||
wordList(0),
|
DynamicList<word>(0),
|
||||||
formatter(NULL)
|
formatter(NULL)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct for a particular surface format
|
//- Construct for a particular surface format
|
||||||
fieldGroup(const word& writeFormat)
|
fieldGroup(const word& writeFormat)
|
||||||
:
|
:
|
||||||
wordList(0),
|
DynamicList<word>(0),
|
||||||
formatter(surfaceWriter<Type>::New(writeFormat))
|
formatter(surfaceWriter<Type>::New(writeFormat))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -93,10 +93,17 @@ class sampledSurfaces
|
|||||||
const wordList& fieldNames
|
const wordList& fieldNames
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
wordList(fieldNames),
|
DynamicList<word>(fieldNames),
|
||||||
formatter(surfaceWriter<Type>::New(writeFormat))
|
formatter(surfaceWriter<Type>::New(writeFormat))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
void reset(const label nElem)
|
||||||
|
{
|
||||||
|
formatter.clear();
|
||||||
|
DynamicList<word>::setCapacity(nElem);
|
||||||
|
DynamicList<word>::clear();
|
||||||
|
}
|
||||||
|
|
||||||
void operator=(const word& writeFormat)
|
void operator=(const word& writeFormat)
|
||||||
{
|
{
|
||||||
formatter = surfaceWriter<Type>::New(writeFormat);
|
formatter = surfaceWriter<Type>::New(writeFormat);
|
||||||
@ -104,7 +111,7 @@ class sampledSurfaces
|
|||||||
|
|
||||||
void operator=(const wordList& fieldNames)
|
void operator=(const wordList& fieldNames)
|
||||||
{
|
{
|
||||||
wordList::operator=(fieldNames);
|
DynamicList<word>::operator=(fieldNames);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -171,6 +178,9 @@ class sampledSurfaces
|
|||||||
|
|
||||||
// Calculated
|
// Calculated
|
||||||
|
|
||||||
|
//- Generic surface formatter
|
||||||
|
autoPtr< surfaceWriter<bool> > genericFormatter_;
|
||||||
|
|
||||||
//- Categorized scalar/vector/tensor fields
|
//- Categorized scalar/vector/tensor fields
|
||||||
fieldGroup<scalar> scalarFields_;
|
fieldGroup<scalar> scalarFields_;
|
||||||
fieldGroup<vector> vectorFields_;
|
fieldGroup<vector> vectorFields_;
|
||||||
@ -181,16 +191,11 @@ class sampledSurfaces
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Classify field types, return true if nFields > 0
|
//- Classify field types, returns the number of fields
|
||||||
bool checkFieldTypes();
|
label classifyFieldTypes();
|
||||||
|
|
||||||
//- Find the fields in the list of the given type, return count
|
//- Write geometry only
|
||||||
template<class Type>
|
void writeGeometry() const;
|
||||||
label grep
|
|
||||||
(
|
|
||||||
fieldGroup<Type>& fieldList,
|
|
||||||
const wordList& fieldTypes
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Sample and write a particular volume field
|
//- Sample and write a particular volume field
|
||||||
template<class Type>
|
template<class Type>
|
||||||
|
@ -30,35 +30,6 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::label Foam::sampledSurfaces::grep
|
|
||||||
(
|
|
||||||
fieldGroup<Type>& fieldList,
|
|
||||||
const wordList& fieldTypes
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
fieldList.setSize(fieldNames_.size());
|
|
||||||
label nFields = 0;
|
|
||||||
|
|
||||||
forAll(fieldNames_, fieldI)
|
|
||||||
{
|
|
||||||
if
|
|
||||||
(
|
|
||||||
fieldTypes[fieldI]
|
|
||||||
== GeometricField<Type, fvPatchField, volMesh>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
fieldList[nFields] = fieldNames_[fieldI];
|
|
||||||
nFields++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldList.setSize(nFields);
|
|
||||||
|
|
||||||
return nFields;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::sampledSurfaces::sampleAndWrite
|
void Foam::sampledSurfaces::sampleAndWrite
|
||||||
(
|
(
|
||||||
@ -67,10 +38,10 @@ void Foam::sampledSurfaces::sampleAndWrite
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// interpolator for this field
|
// interpolator for this field
|
||||||
autoPtr<interpolation<Type> > interpolator;
|
autoPtr< interpolation<Type> > interpolator;
|
||||||
|
|
||||||
const word& fieldName = vField.name();
|
const word& fieldName = vField.name();
|
||||||
const fileName& timeDir = vField.time().timeName();
|
const fileName outputDir = outputPath_/vField.time().timeName();
|
||||||
|
|
||||||
forAll(*this, surfI)
|
forAll(*this, surfI)
|
||||||
{
|
{
|
||||||
@ -128,8 +99,7 @@ void Foam::sampledSurfaces::sampleAndWrite
|
|||||||
{
|
{
|
||||||
formatter.write
|
formatter.write
|
||||||
(
|
(
|
||||||
outputPath_,
|
outputDir,
|
||||||
timeDir,
|
|
||||||
s.name(),
|
s.name(),
|
||||||
mergeList_[surfI].points,
|
mergeList_[surfI].points,
|
||||||
mergeList_[surfI].faces,
|
mergeList_[surfI].faces,
|
||||||
@ -147,8 +117,7 @@ void Foam::sampledSurfaces::sampleAndWrite
|
|||||||
{
|
{
|
||||||
formatter.write
|
formatter.write
|
||||||
(
|
(
|
||||||
outputPath_,
|
outputDir,
|
||||||
timeDir,
|
|
||||||
s.name(),
|
s.name(),
|
||||||
s.points(),
|
s.points(),
|
||||||
s.faces(),
|
s.faces(),
|
||||||
@ -217,7 +186,7 @@ void Foam::sampledSurfaces::sampleAndWrite
|
|||||||
sampleAndWrite
|
sampleAndWrite
|
||||||
(
|
(
|
||||||
mesh_.lookupObject
|
mesh_.lookupObject
|
||||||
<GeometricField<Type, fvPatchField, volMesh> >
|
<GeometricField<Type, fvPatchField, volMesh> >
|
||||||
(
|
(
|
||||||
fields[fieldI]
|
fields[fieldI]
|
||||||
),
|
),
|
||||||
|
@ -26,9 +26,7 @@ License
|
|||||||
|
|
||||||
#include "dxSurfaceWriter.H"
|
#include "dxSurfaceWriter.H"
|
||||||
|
|
||||||
#include "fileName.H"
|
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "faceList.H"
|
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
@ -247,8 +245,7 @@ Foam::dxSurfaceWriter<Type>::~dxSurfaceWriter()
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::dxSurfaceWriter<Type>::write
|
void Foam::dxSurfaceWriter<Type>::write
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
@ -257,22 +254,21 @@ void Foam::dxSurfaceWriter<Type>::write
|
|||||||
const bool verbose
|
const bool verbose
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
fileName surfaceDir(samplePath/timeDir);
|
if (!isDir(outputDir))
|
||||||
|
|
||||||
if (!isDir(surfaceDir))
|
|
||||||
{
|
{
|
||||||
mkDir(surfaceDir);
|
mkDir(outputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName fName(surfaceDir/fieldName + '_' + surfaceName + ".dx");
|
OFstream os
|
||||||
|
(
|
||||||
|
outputDir/fieldName + '_' + surfaceName + ".dx"
|
||||||
|
);
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
Info<< "Writing field " << fieldName << " to " << fName << endl;
|
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
OFstream os(fName);
|
|
||||||
|
|
||||||
writeGeometry(os, points, faces);
|
writeGeometry(os, points, faces);
|
||||||
|
|
||||||
writeData(os, values);
|
writeData(os, values);
|
||||||
|
@ -84,8 +84,7 @@ public:
|
|||||||
//- Writes single surface to file.
|
//- Writes single surface to file.
|
||||||
virtual void write
|
virtual void write
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
|
@ -26,9 +26,7 @@ License
|
|||||||
|
|
||||||
#include "foamFileSurfaceWriter.H"
|
#include "foamFileSurfaceWriter.H"
|
||||||
|
|
||||||
#include "fileName.H"
|
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "faceList.H"
|
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
@ -49,22 +47,17 @@ Foam::foamFileSurfaceWriter<Type>::~foamFileSurfaceWriter()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
template<class Type>
|
||||||
{
|
void Foam::foamFileSurfaceWriter<Type>::write
|
||||||
template<>
|
|
||||||
void Foam::foamFileSurfaceWriter<Foam::nil>::write
|
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
const fileName& fieldName,
|
|
||||||
const Field<Foam::nil>& values,
|
|
||||||
const bool verbose
|
const bool verbose
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
fileName surfaceDir(samplePath/timeDir/surfaceName);
|
fileName surfaceDir(outputDir/surfaceName);
|
||||||
|
|
||||||
if (!isDir(surfaceDir))
|
if (!isDir(surfaceDir))
|
||||||
{
|
{
|
||||||
@ -73,7 +66,7 @@ void Foam::foamFileSurfaceWriter<Foam::nil>::write
|
|||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
Info<< "Writing nil to " << surfaceDir << endl;
|
Info<< "Writing geometry to " << surfaceDir << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Points
|
// Points
|
||||||
@ -83,14 +76,11 @@ void Foam::foamFileSurfaceWriter<Foam::nil>::write
|
|||||||
OFstream(surfaceDir/"faces")() << faces;
|
OFstream(surfaceDir/"faces")() << faces;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::foamFileSurfaceWriter<Type>::write
|
void Foam::foamFileSurfaceWriter<Type>::write
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
@ -99,7 +89,7 @@ void Foam::foamFileSurfaceWriter<Type>::write
|
|||||||
const bool verbose
|
const bool verbose
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
fileName surfaceDir(samplePath/timeDir/surfaceName);
|
fileName surfaceDir(outputDir/surfaceName);
|
||||||
|
|
||||||
if (!isDir(surfaceDir))
|
if (!isDir(surfaceDir))
|
||||||
{
|
{
|
||||||
@ -111,11 +101,7 @@ void Foam::foamFileSurfaceWriter<Type>::write
|
|||||||
Info<< "Writing field " << fieldName << " to " << surfaceDir << endl;
|
Info<< "Writing field " << fieldName << " to " << surfaceDir << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Points
|
// geometry should already have been written
|
||||||
OFstream(surfaceDir/"points")() << points;
|
|
||||||
|
|
||||||
// Faces
|
|
||||||
OFstream(surfaceDir/"faces")() << faces;
|
|
||||||
|
|
||||||
// Values to separate directory (e.g. "scalarField/p")
|
// Values to separate directory (e.g. "scalarField/p")
|
||||||
|
|
||||||
|
@ -72,13 +72,26 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Write
|
//- Return true if the surface format supports separate files
|
||||||
|
virtual bool separateFiles()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Write geometry to file.
|
||||||
|
virtual void write
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const bool verbose = false
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Writes single surface to file.
|
//- Writes single surface to file.
|
||||||
virtual void write
|
virtual void write
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
|
@ -35,7 +35,7 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
makeSurfaceWriterType(foamFileSurfaceWriter, nil);
|
makeSurfaceWriterType(foamFileSurfaceWriter, bool);
|
||||||
makeSurfaceWriters(foamFileSurfaceWriter);
|
makeSurfaceWriters(foamFileSurfaceWriter);
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
@ -25,10 +25,6 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "nullSurfaceWriter.H"
|
#include "nullSurfaceWriter.H"
|
||||||
#include "fileName.H"
|
|
||||||
#include "OFstream.H"
|
|
||||||
#include "faceList.H"
|
|
||||||
#include "OSspecific.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -53,8 +49,7 @@ Foam::nullSurfaceWriter<Type>::~nullSurfaceWriter()
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::nullSurfaceWriter<Type>::write
|
void Foam::nullSurfaceWriter<Type>::write
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
|
@ -76,8 +76,7 @@ public:
|
|||||||
//- Writes single surface to file.
|
//- Writes single surface to file.
|
||||||
virtual void write
|
virtual void write
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
|
@ -35,7 +35,7 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
makeSurfaceWriterType(nullSurfaceWriter, nil);
|
makeSurfaceWriterType(nullSurfaceWriter, bool);
|
||||||
makeSurfaceWriters(nullSurfaceWriter);
|
makeSurfaceWriters(nullSurfaceWriter);
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
@ -26,9 +26,8 @@ License
|
|||||||
|
|
||||||
#include "objSurfaceWriter.H"
|
#include "objSurfaceWriter.H"
|
||||||
|
|
||||||
#include "fileName.H"
|
#include "MeshedSurfaceProxy.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "faceList.H"
|
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
@ -49,146 +48,33 @@ Foam::objSurfaceWriter<Type>::~objSurfaceWriter()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
template<>
|
|
||||||
void Foam::objSurfaceWriter<Foam::nil>::write
|
|
||||||
(
|
|
||||||
const fileName& samplePath,
|
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
|
||||||
const pointField& points,
|
|
||||||
const faceList& faces,
|
|
||||||
const fileName& fieldName,
|
|
||||||
const Field<Foam::nil>& values,
|
|
||||||
const bool verbose
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
fileName surfaceDir(samplePath/timeDir);
|
|
||||||
|
|
||||||
if (!isDir(surfaceDir))
|
|
||||||
{
|
|
||||||
mkDir(surfaceDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
fileName fName(surfaceDir/surfaceName + ".obj");
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
Info<< "Writing nil to " << fName << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this is a quick hack
|
|
||||||
OFstream os(fName);
|
|
||||||
|
|
||||||
os << "# Wavefront OBJ file" << nl
|
|
||||||
<< "o " << os.name().lessExt().name() << nl
|
|
||||||
<< nl
|
|
||||||
<< "# points : " << points.size() << nl
|
|
||||||
<< "# faces : " << faces.size() << nl
|
|
||||||
<< "# no zones " << nl;
|
|
||||||
|
|
||||||
os << nl
|
|
||||||
<< "# <points count=\"" << points.size() << "\">" << endl;
|
|
||||||
|
|
||||||
// Write vertex coords
|
|
||||||
forAll(points, ptI)
|
|
||||||
{
|
|
||||||
os << "v " << points[ptI].x()
|
|
||||||
<< ' ' << points[ptI].y()
|
|
||||||
<< ' ' << points[ptI].z() << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
os << "# </points>" << nl
|
|
||||||
<< nl
|
|
||||||
<< "# <faces count=\"" << faces.size() << "\">" << endl;
|
|
||||||
|
|
||||||
forAll(faces, i)
|
|
||||||
{
|
|
||||||
const face& f = faces[i];
|
|
||||||
|
|
||||||
os << 'f';
|
|
||||||
forAll(f, fp)
|
|
||||||
{
|
|
||||||
os << ' ' << f[fp] + 1;
|
|
||||||
}
|
|
||||||
os << nl;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
os << "# </faces>" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::objSurfaceWriter<Type>::write
|
void Foam::objSurfaceWriter<Type>::write
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
const fileName& fieldName,
|
|
||||||
const Field<Type>& values,
|
|
||||||
const bool verbose
|
const bool verbose
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
fileName surfaceDir(samplePath/timeDir);
|
if (!isDir(outputDir))
|
||||||
|
|
||||||
if (!isDir(surfaceDir))
|
|
||||||
{
|
{
|
||||||
mkDir(surfaceDir);
|
mkDir(outputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName fName(surfaceDir/surfaceName + ".obj");
|
fileName fName(outputDir/surfaceName + ".obj");
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
Info<< "Writing field " << fieldName << " to " << fName << endl;
|
Info<< "Writing geometry to " << fName << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is a quick hack
|
MeshedSurfaceProxy<face>
|
||||||
OFstream os(fName);
|
(
|
||||||
|
points,
|
||||||
os << "# Wavefront OBJ file" << nl
|
faces
|
||||||
<< "o " << os.name().lessExt().name() << nl
|
).write(fName);
|
||||||
<< nl
|
|
||||||
<< "# points : " << points.size() << nl
|
|
||||||
<< "# faces : " << faces.size() << nl
|
|
||||||
<< "# no zones " << nl;
|
|
||||||
|
|
||||||
os << nl
|
|
||||||
<< "# <points count=\"" << points.size() << "\">" << endl;
|
|
||||||
|
|
||||||
// Write vertex coords
|
|
||||||
forAll(points, ptI)
|
|
||||||
{
|
|
||||||
os << "v " << points[ptI].x()
|
|
||||||
<< ' ' << points[ptI].y()
|
|
||||||
<< ' ' << points[ptI].z() << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
os << "# </points>" << nl
|
|
||||||
<< nl
|
|
||||||
<< "# <faces count=\"" << faces.size() << "\">" << endl;
|
|
||||||
|
|
||||||
forAll(faces, i)
|
|
||||||
{
|
|
||||||
const face& f = faces[i];
|
|
||||||
|
|
||||||
os << 'f';
|
|
||||||
forAll(f, fp)
|
|
||||||
{
|
|
||||||
os << ' ' << f[fp] + 1;
|
|
||||||
}
|
|
||||||
os << nl;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
os << "# </faces>" << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,20 +71,37 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Always write separate geometry file
|
||||||
|
virtual bool separateFiles()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
||||||
|
//- Write geometry to file.
|
||||||
|
virtual void write
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const bool verbose = false
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
//- Writes single surface to file.
|
//- Writes single surface to file.
|
||||||
virtual void write
|
virtual void write
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
const fileName& fieldName,
|
const fileName& fieldName,
|
||||||
const Field<Type>& values,
|
const Field<Type>& values,
|
||||||
const bool verbose = false
|
const bool verbose = false
|
||||||
) const;
|
) const
|
||||||
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,8 +35,7 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
makeSurfaceWriterType(objSurfaceWriter, nil);
|
makeSurfaceWriterType(objSurfaceWriter, bool);
|
||||||
makeSurfaceWriters(objSurfaceWriter);
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
@ -26,9 +26,7 @@ License
|
|||||||
|
|
||||||
#include "rawSurfaceWriter.H"
|
#include "rawSurfaceWriter.H"
|
||||||
|
|
||||||
#include "fileName.H"
|
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "faceList.H"
|
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
#include "IOmanip.H"
|
#include "IOmanip.H"
|
||||||
|
|
||||||
@ -295,37 +293,31 @@ Foam::rawSurfaceWriter<Type>::~rawSurfaceWriter()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
template<class Type>
|
||||||
{
|
void Foam::rawSurfaceWriter<Type>::write
|
||||||
|
|
||||||
template<>
|
|
||||||
void Foam::rawSurfaceWriter<Foam::nil>::write
|
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
const fileName& fieldName,
|
|
||||||
const Field<Foam::nil>& values,
|
|
||||||
const bool verbose
|
const bool verbose
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
fileName surfaceDir(samplePath/timeDir);
|
if (!isDir(outputDir))
|
||||||
|
|
||||||
if (!isDir(surfaceDir))
|
|
||||||
{
|
{
|
||||||
mkDir(surfaceDir);
|
mkDir(outputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName fName(surfaceDir/surfaceName + ".raw");
|
OFstream os
|
||||||
|
(
|
||||||
|
outputDir/surfaceName + ".raw"
|
||||||
|
);
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
Info<< "Writing nil to " << fName << endl;
|
Info<< "Writing geometry to " << os.name() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
OFstream os(fName);
|
|
||||||
|
|
||||||
// header
|
// header
|
||||||
os << "# geometry NO_DATA " << faces.size() << nl
|
os << "# geometry NO_DATA " << faces.size() << nl
|
||||||
@ -341,14 +333,29 @@ void Foam::rawSurfaceWriter<Foam::nil>::write
|
|||||||
os << nl;
|
os << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
// bool fields aren't supported
|
||||||
|
template<>
|
||||||
|
void Foam::rawSurfaceWriter<bool>::write
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const fileName& fieldName,
|
||||||
|
const Field<bool>& values,
|
||||||
|
const bool verbose
|
||||||
|
) const
|
||||||
|
{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::rawSurfaceWriter<Type>::write
|
void Foam::rawSurfaceWriter<Type>::write
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
@ -357,21 +364,21 @@ void Foam::rawSurfaceWriter<Type>::write
|
|||||||
const bool verbose
|
const bool verbose
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
fileName surfaceDir(samplePath/timeDir);
|
if (!isDir(outputDir))
|
||||||
|
|
||||||
if (!isDir(surfaceDir))
|
|
||||||
{
|
{
|
||||||
mkDir(surfaceDir);
|
mkDir(outputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName fName(surfaceDir/fieldName + '_' + surfaceName + ".raw");
|
OFstream os
|
||||||
|
(
|
||||||
|
outputDir/fieldName + '_' + surfaceName + ".raw"
|
||||||
|
);
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
Info<< "Writing field " << fieldName << " to " << fName << endl;
|
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
OFstream os(fName);
|
|
||||||
|
|
||||||
// header
|
// header
|
||||||
os << "# " << fieldName;
|
os << "# " << fieldName;
|
||||||
|
@ -135,11 +135,20 @@ public:
|
|||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
||||||
|
//- Write geometry to file.
|
||||||
|
virtual void write
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const bool verbose = false
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Writes single surface to file.
|
//- Writes single surface to file.
|
||||||
virtual void write
|
virtual void write
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
|
@ -35,7 +35,7 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
makeSurfaceWriterType(rawSurfaceWriter, nil);
|
makeSurfaceWriterType(rawSurfaceWriter, bool);
|
||||||
makeSurfaceWriters(rawSurfaceWriter);
|
makeSurfaceWriters(rawSurfaceWriter);
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
@ -25,11 +25,10 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "stlSurfaceWriter.H"
|
#include "stlSurfaceWriter.H"
|
||||||
#include "fileName.H"
|
|
||||||
|
#include "MeshedSurfaceProxy.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "faceList.H"
|
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
#include "triSurface.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -49,134 +48,34 @@ Foam::stlSurfaceWriter<Type>::~stlSurfaceWriter()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
template<>
|
|
||||||
void Foam::stlSurfaceWriter<Foam::nil>::write
|
|
||||||
(
|
|
||||||
const fileName& samplePath,
|
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
|
||||||
const pointField& points,
|
|
||||||
const faceList& faces,
|
|
||||||
const fileName& fieldName,
|
|
||||||
const Field<Foam::nil>& values,
|
|
||||||
const bool verbose
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
fileName surfaceDir(samplePath/timeDir);
|
|
||||||
|
|
||||||
if (!isDir(surfaceDir))
|
|
||||||
{
|
|
||||||
mkDir(surfaceDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
fileName fName(surfaceDir/surfaceName + ".stl");
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
Info<< "Writing nil to " << fName << 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
|
|
||||||
"patch0", // fieldName
|
|
||||||
0 // index
|
|
||||||
)
|
|
||||||
),
|
|
||||||
points
|
|
||||||
).write(fName);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::stlSurfaceWriter<Type>::write
|
void Foam::stlSurfaceWriter<Type>::write
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
const fileName& fieldName,
|
|
||||||
const Field<Type>& values,
|
|
||||||
const bool verbose
|
const bool verbose
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
fileName surfaceDir(samplePath/timeDir);
|
if (!isDir(outputDir))
|
||||||
|
|
||||||
if (!isDir(surfaceDir))
|
|
||||||
{
|
{
|
||||||
mkDir(surfaceDir);
|
mkDir(outputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName fName(surfaceDir/surfaceName + ".stl");
|
fileName fName(outputDir/surfaceName + ".stl");
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
Info<< "Writing field " << fieldName << " to " << fName << endl;
|
Info<< "Writing geometry to " << fName << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert faces to triangles.
|
MeshedSurfaceProxy<face>
|
||||||
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(),
|
points,
|
||||||
geometricSurfacePatchList
|
faces
|
||||||
(
|
|
||||||
1,
|
|
||||||
geometricSurfacePatch
|
|
||||||
(
|
|
||||||
"patch", // geometricType
|
|
||||||
string::validate<word>(fieldName), // fieldName
|
|
||||||
0 // index
|
|
||||||
)
|
|
||||||
),
|
|
||||||
points
|
|
||||||
).write(fName);
|
).write(fName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,20 +71,37 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Always write separate geometry file
|
||||||
|
virtual bool separateFiles()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
||||||
|
//- Write geometry to file.
|
||||||
|
virtual void write
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const bool verbose = false
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Writes single surface to file.
|
//- Writes single surface to file.
|
||||||
virtual void write
|
virtual void write
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
const fileName& fieldName,
|
const fileName& fieldName,
|
||||||
const Field<Type>& values,
|
const Field<Type>& values,
|
||||||
const bool verbose = false
|
const bool verbose = false
|
||||||
) const;
|
) const
|
||||||
|
{}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,8 +35,7 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
makeSurfaceWriterType(stlSurfaceWriter, nil);
|
makeSurfaceWriterType(stlSurfaceWriter, bool);
|
||||||
makeSurfaceWriters(stlSurfaceWriter);
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ License
|
|||||||
#include "surfaceWriter.H"
|
#include "surfaceWriter.H"
|
||||||
#include "HashTable.H"
|
#include "HashTable.H"
|
||||||
#include "word.H"
|
#include "word.H"
|
||||||
#include "fileName.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -40,13 +39,13 @@ Foam::surfaceWriter<Type>::New(const word& writeType)
|
|||||||
|
|
||||||
if (cstrIter == wordConstructorTablePtr_->end())
|
if (cstrIter == wordConstructorTablePtr_->end())
|
||||||
{
|
{
|
||||||
// unknown, check if it can handle Foam::nil specialization
|
// unknown, check if it can handle 'bool' specialization
|
||||||
// (ie, geometry write)
|
// (ie, geometry write)
|
||||||
|
|
||||||
// generally supported, but not for this data type
|
// generally supported, but not for this data type
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
Foam::surfaceWriter<Foam::nil>::wordConstructorTablePtr_->found
|
Foam::surfaceWriter<bool>::wordConstructorTablePtr_->found
|
||||||
(
|
(
|
||||||
writeType
|
writeType
|
||||||
)
|
)
|
||||||
@ -88,4 +87,6 @@ Foam::surfaceWriter<Type>::~surfaceWriter()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
@ -37,11 +37,12 @@ SourceFiles
|
|||||||
|
|
||||||
#include "Field.H"
|
#include "Field.H"
|
||||||
#include "typeInfo.H"
|
#include "typeInfo.H"
|
||||||
#include "runTimeSelectionTables.H"
|
|
||||||
#include "autoPtr.H"
|
#include "autoPtr.H"
|
||||||
#include "pointField.H"
|
#include "pointField.H"
|
||||||
#include "faceList.H"
|
#include "faceList.H"
|
||||||
#include "nil.H"
|
#include "fileName.H"
|
||||||
|
|
||||||
|
#include "runTimeSelectionTables.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -98,12 +99,30 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Return true if the surface format supports separate files
|
||||||
|
virtual bool separateFiles()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Writes single surface geometry to file.
|
||||||
|
virtual void write
|
||||||
|
(
|
||||||
|
const fileName& outputDir, // <root>/<case>/surface/TIME
|
||||||
|
const fileName& surfaceName, // name of surface
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const bool verbose = false
|
||||||
|
) const
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
//- Writes single surface to file. Either one value per vertex or
|
//- Writes single surface to file. Either one value per vertex or
|
||||||
// one value per face (detected by values.size()==faces.size())
|
// one value per face (detected by values.size()==faces.size())
|
||||||
virtual void write
|
virtual void write
|
||||||
(
|
(
|
||||||
const fileName& samplePath, // <root>/<case>/sampleSurfaces
|
const fileName& outputDir, // <root>/<case>/surface/TIME
|
||||||
const fileName& timeDir, // time directory
|
|
||||||
const fileName& surfaceName, // name of surface
|
const fileName& surfaceName, // name of surface
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
|
@ -36,7 +36,7 @@ namespace Foam
|
|||||||
defineNamedTemplateTypeNameAndDebug(surfaceWriter< dataType >, 0); \
|
defineNamedTemplateTypeNameAndDebug(surfaceWriter< dataType >, 0); \
|
||||||
defineTemplatedRunTimeSelectionTable(surfaceWriter, word, dataType)
|
defineTemplatedRunTimeSelectionTable(surfaceWriter, word, dataType)
|
||||||
|
|
||||||
defineSurfaceWriterType(nil);
|
defineSurfaceWriterType(bool);
|
||||||
|
|
||||||
defineSurfaceWriterType(scalar);
|
defineSurfaceWriterType(scalar);
|
||||||
defineSurfaceWriterType(vector);
|
defineSurfaceWriterType(vector);
|
||||||
|
@ -26,9 +26,7 @@ License
|
|||||||
|
|
||||||
#include "vtkSurfaceWriter.H"
|
#include "vtkSurfaceWriter.H"
|
||||||
|
|
||||||
#include "fileName.H"
|
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "faceList.H"
|
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
@ -198,7 +196,7 @@ namespace Foam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Write tensorField in vtk format
|
// Write generic field in vtk format
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::vtkSurfaceWriter<Type>::writeData
|
void Foam::vtkSurfaceWriter<Type>::writeData
|
||||||
(
|
(
|
||||||
@ -234,47 +232,37 @@ Foam::vtkSurfaceWriter<Type>::~vtkSurfaceWriter()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
template<class Type>
|
||||||
{
|
void Foam::vtkSurfaceWriter<Type>::write
|
||||||
template<>
|
|
||||||
void Foam::vtkSurfaceWriter<Foam::nil>::write
|
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
const fileName& fieldName,
|
|
||||||
const Field<Foam::nil>& values,
|
|
||||||
const bool verbose
|
const bool verbose
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
fileName surfaceDir(samplePath/timeDir);
|
if (!isDir(outputDir))
|
||||||
|
|
||||||
if (!isDir(surfaceDir))
|
|
||||||
{
|
{
|
||||||
mkDir(surfaceDir);
|
mkDir(outputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName fName(surfaceDir/surfaceName + ".vtk");
|
fileName fName(outputDir/surfaceName + ".vtk");
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
Info<< "Writing nil to " << fName << endl;
|
Info<< "Writing geometry to " << fName << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
OFstream os(fName);
|
OFstream os(fName);
|
||||||
writeGeometry(os, points, faces);
|
writeGeometry(os, points, faces);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::vtkSurfaceWriter<Type>::write
|
void Foam::vtkSurfaceWriter<Type>::write
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
@ -283,21 +271,21 @@ void Foam::vtkSurfaceWriter<Type>::write
|
|||||||
const bool verbose
|
const bool verbose
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
fileName surfaceDir(samplePath/timeDir);
|
if (!isDir(outputDir))
|
||||||
|
|
||||||
if (!isDir(surfaceDir))
|
|
||||||
{
|
{
|
||||||
mkDir(surfaceDir);
|
mkDir(outputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName fName(surfaceDir/fieldName + '_' + surfaceName + ".vtk");
|
OFstream os
|
||||||
|
(
|
||||||
|
outputDir/fieldName + '_' + surfaceName + ".vtk"
|
||||||
|
);
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
Info<< "Writing field " << fieldName << " to " << fName << endl;
|
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
OFstream os(fName);
|
|
||||||
writeGeometry(os, points, faces);
|
writeGeometry(os, points, faces);
|
||||||
|
|
||||||
// start writing data
|
// start writing data
|
||||||
|
@ -79,11 +79,21 @@ public:
|
|||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
||||||
|
//- Write geometry to file.
|
||||||
|
virtual void write
|
||||||
|
(
|
||||||
|
const fileName& outputDir,
|
||||||
|
const fileName& surfaceName,
|
||||||
|
const pointField& points,
|
||||||
|
const faceList& faces,
|
||||||
|
const bool verbose = false
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
//- Writes single surface to file.
|
//- Writes single surface to file.
|
||||||
virtual void write
|
virtual void write
|
||||||
(
|
(
|
||||||
const fileName& samplePath,
|
const fileName& outputDir,
|
||||||
const fileName& timeDir,
|
|
||||||
const fileName& surfaceName,
|
const fileName& surfaceName,
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
const faceList& faces,
|
const faceList& faces,
|
||||||
|
@ -35,7 +35,7 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
makeSurfaceWriterType(vtkSurfaceWriter, nil);
|
makeSurfaceWriterType(vtkSurfaceWriter, bool);
|
||||||
makeSurfaceWriters(vtkSurfaceWriter);
|
makeSurfaceWriters(vtkSurfaceWriter);
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
Loading…
Reference in New Issue
Block a user