Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (4)
ensightMeshReader.C
ensightToFoam.C
EXE = $(FOAM_APPBIN)/ensightToFoam
EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude
EXE_LIBS = \
-lfileFormats \
-lsurfMesh \
-lmeshTools \
-lconversion
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fileFormats::ensightMeshReader
Description
Notes
SourceFiles
ensightMeshReader.C
\*---------------------------------------------------------------------------*/
#ifndef Foam_ensightMeshReader_H
#define Foam_ensightMeshReader_H
#include "meshReader.H"
//#include "ensightReadFile.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward Declarations
class ensightReadFile;
namespace fileFormats
{
/*---------------------------------------------------------------------------*\
Class fileFormats::ensightMeshReader Declaration
\*---------------------------------------------------------------------------*/
class ensightMeshReader
:
public meshReader
{
// Private Data
//- Merge distance
const scalar mergeTol_;
//- Check and correct handedness
const bool setHandedness_;
protected:
// Protected Data
//- mesh point to original node_id
labelList nodeIds_;
//- mesh cell to original element_id
labelList elementIds_;
// Protected Member Functions
//- Rotate face so lowest vertex is first
const face& rotateFace
(
const face& f,
face& rotatedFace
) const;
//- Read set of vertices. Optional mapping
void readVerts
(
ensightReadFile& is,
const label nVerts,
const Map<label>& nodeIdToPoints,
DynamicList<label>& verts
) const;
//- Read set of element/node IDs
void readIDs
(
ensightReadFile& is,
const bool doRead,
const label nShapes,
labelList& foamToElem,
Map<label>& elemToFoam
) const;
//- Swap handedness of hex if needed
void setHandedness
(
const cellModel& model,
DynamicList<label>& verts,
const pointField& points
) const;
//- Read a single part until eof (return true) or until start of next
// part (return false)
bool readGoldPart
(
ensightReadFile& is,
const bool read_node_ids,
const bool read_elem_ids,
pointField& points,
labelList& pointToNodeIds,
Map<label>& nodeIdToPoints,
// 3D-elems : cells (cell-to-faces)
faceListList& cellFaces,
labelList& cellToElemIds,
Map<label>& elemIdToCells,
// 2D-elems : faces
faceList& faces,
labelList& faceToElemIDs,
Map<label>& elemIdToFaces
) const;
//- Read the mesh from the file(s)
virtual bool readGeometry(const scalar scaleFactor = 1.0);
public:
//- Runtime type information
TypeName("ensightMeshReader");
// Constructors
//- Construct from case name
ensightMeshReader
(
const fileName& geomFile,
const objectRegistry& registry,
const scalar mergeTol = SMALL,
const scalar scaleFactor = 1.0,
const bool setHandedness = true
);
//- Destructor
virtual ~ensightMeshReader() = default;
// Access
//- Original node id (if supplied) or -1
const labelList& nodeIds() const noexcept
{
return nodeIds_;
}
//- Original element id (if supplied) or -1
const labelList& elementIds() const noexcept
{
return elementIds_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fileFormats
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
ensightToFoam
Group
grpMeshConversionUtilities
Description
Convert an Ensight Gold mesh into OpenFOAM format.
Usage
\b ensightToFoam [OPTION] \<ensightGeometryFile\>
Options:
- \par -mergeTol \<factor\>
Specify an alternative merging tolerance as a fraction of
the bounding box of the points.
- \par -scale \<factor\>
Specify an optional geometry scaling factor.
- \par -keepHandedness
Do not automatically flip negative volume cells
See also
Foam::meshReader and Foam::fileFormats::STARCDMeshReader
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "ensightMeshReader.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"Convert Ensight mesh to OpenFOAM"
);
argList::noParallel();
argList::addArgument(".geo file", "The file containing the geometry");
argList::addOption
(
"mergeTol",
"factor",
"Merge tolerance as a fraction of bounding box - 0 to disable merging"
);
argList::addOption
(
"scale",
"factor",
"Geometry scaling factor - default is 1"
);
argList::addBoolOption
(
"keepHandedness",
"Do not automatically flip inverted cells"
" (default is to do a geometric test)"
);
argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName());
// Increase the precision of the points data
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
const fileName geomFile(args.get<fileName>(1));
{
fileFormats::ensightMeshReader reader
(
geomFile,
runTime,
args.getOrDefault<scalar>("mergeTol", 1e-10),
args.getOrDefault<scalar>("scale", 1.0),
args.found("keepHandedness")
);
autoPtr<polyMesh> mesh = reader.mesh(runTime);
mesh().setInstance(runTime.constant());
mesh().write();
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -84,7 +84,7 @@ Foam::points0MotionSolver::points0MotionSolver
)
:
motionSolver(mesh, dict, type),
zoneMotion(dict, mesh),
zoneMotion(coeffDict(), mesh),
points0_(points0IO(mesh))
{
if
......@@ -128,7 +128,7 @@ Foam::points0MotionSolver::points0MotionSolver
)
:
motionSolver(mesh, dict, type),
zoneMotion(dict, mesh),
zoneMotion(coeffDict(), mesh),
points0_(points0)
{
if (points0_.size() != mesh.nPoints())
......