87 auto&
fld = tfld.ref();
88 fld.instance() =
mesh.time().timeName();
92 fld.internalFieldRef().field() =
96 const auto& map = reader.
faceMap();
99 for (
auto& pfld :
fld.boundaryFieldRef())
101 const auto&
pp = pfld.patch();
105 const label bFacei =
pp.patch().offset()+i;
106 pfld[i] =
field[map[bFacei]];
116int main(
int argc,
char *argv[])
120 "Convert legacy VTK file (ascii) containing an unstructured grid"
121 " to an OpenFOAM mesh without boundary information"
131 const bool doFields = !
args.found(
"no-fields");
145 std::move(reader.
points()),
167 Info<<
"Re-reading mesh ..." <<
endl;
170 constructVolFields<scalar>(
mesh, reader);
171 constructVolFields<vector>(
mesh, reader);
172 constructVolFields<sphericalTensor>(
mesh, reader);
173 constructVolFields<symmTensor>(
mesh, reader);
174 constructVolFields<tensor>(
mesh, reader);
177 mesh.thisDb().write();
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=PatchField< Type >::calculatedType())
Return tmp field (NO_READ, NO_WRITE) from name, mesh, dimensions and patch type. [Takes current timeN...
Input from file stream as an ISstream, normally using std::ifstream for the actual input.
A primitive field of type <T> with automated input and output.
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static unsigned int minPrecision(unsigned int prec) noexcept
Set the minimum default precision.
A List with indirect addressing. Like IndirectList but does not store addressing.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
static void noParallel()
Remove the parallel options.
static void addNote(const string ¬e)
Add extra notes for the usage information.
static void addOptionCompat(const word &optName, std::pair< const char *, int > compat)
Specify an alias for the option name.
A class for handling file names.
Mesh data needed to do the Finite Volume discretisation.
UPtrList< const Type > csorted() const
Return sorted list of objects with a class satisfying isA<Type> or isType<Type> (with Strict).
Mesh consisting of general polyhedral cells.
static word defaultRegion
Return the default region name.
bool store()
Register object with its registry and transfer ownership to the registry.
Reader for vtk UNSTRUCTURED_GRID legacy files. Supports single CELLS, POINTS etc. entry only.
const cellShapeList & cells() const noexcept
3D cells
const objectRegistry & cellData() const noexcept
Cell based fields.
const labelList & faceMap() const noexcept
const pointField & points() const noexcept
Points.
const labelList & cellMap() const noexcept
List< word > wordList
List of word.
const dimensionSet dimless
Dimensionless.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< faceList > faceListList
List of faceList.
Foam::argList args(argc, argv)
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
#define forAll(list, i)
Loop across all elements in list.