mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
added surfaceCoordinateSystemTransform
This commit is contained in:
@ -0,0 +1,3 @@
|
|||||||
|
surfaceCoordinateSystemTransform.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_APPBIN)/surfaceCoordinateSystemTransform
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
|
-I$(LIB_SRC)/surfMesh/lnInclude
|
||||||
|
|
||||||
|
EXE_LIBS = -lmeshTools -lsurfMesh
|
||||||
@ -0,0 +1,83 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: dev |
|
||||||
|
| \\ / A nd | Web: http://www.OpenFOAM.org |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class IOPtrList<coordinateSystem>;
|
||||||
|
object coordinateSystems;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
7
|
||||||
|
(
|
||||||
|
system_9
|
||||||
|
{
|
||||||
|
type cartesian;
|
||||||
|
origin (1.03291515 -0.114391257 -0.0826236662);
|
||||||
|
e3 (1 0 0);
|
||||||
|
e1 (0 1 0);
|
||||||
|
// STARCDRotation (0 90 90);
|
||||||
|
}
|
||||||
|
|
||||||
|
system_10
|
||||||
|
{
|
||||||
|
type cartesian;
|
||||||
|
origin (0.623151719 -0.286472935 -0.113933262);
|
||||||
|
e3 (0.99508851 0.09829095 0.01173645);
|
||||||
|
e1 (0.01179356 0 -0.99993045);
|
||||||
|
// STARCDRotation (5.6403745 -0.0664172952 89.3275351);
|
||||||
|
}
|
||||||
|
|
||||||
|
system_15
|
||||||
|
{
|
||||||
|
type cartesian;
|
||||||
|
origin (0.644772231 -0.240036493 0.155972187);
|
||||||
|
e3 (-0.01346388 -0.90616979 -0.42269969);
|
||||||
|
e1 (0.00627978 0.42265304 -0.90626981);
|
||||||
|
// STARCDRotation (-90.8512386 0 115.005148);
|
||||||
|
}
|
||||||
|
|
||||||
|
system_16
|
||||||
|
{
|
||||||
|
type cartesian;
|
||||||
|
origin (0.540824938 -0.240036415 0.15928296);
|
||||||
|
e3 (-0.01346388 -0.90616979 -0.42269969);
|
||||||
|
e1 (0.00627978 0.42265304 -0.90626981);
|
||||||
|
// STARCDRotation (-90.8512386 0 115.005148);
|
||||||
|
}
|
||||||
|
|
||||||
|
system_17
|
||||||
|
{
|
||||||
|
type cartesian;
|
||||||
|
origin (0.436877646 -0.240036339 0.162593737);
|
||||||
|
e3 (-0.01346388 -0.90616979 -0.42269969);
|
||||||
|
e1 (0.00627978 0.42265304 -0.90626981);
|
||||||
|
// STARCDRotation (-90.8512386 0 115.005148);
|
||||||
|
}
|
||||||
|
|
||||||
|
system_18
|
||||||
|
{
|
||||||
|
type cartesian;
|
||||||
|
origin (0.332930354 -0.240036261 0.16590451);
|
||||||
|
e3 (-0.01346388 -0.90616979 -0.42269969);
|
||||||
|
e1 (0.00627978 0.42265304 -0.90626981);
|
||||||
|
// STARCDRotation (-90.8512386 0 115.005148);
|
||||||
|
}
|
||||||
|
|
||||||
|
system_21
|
||||||
|
{
|
||||||
|
type cartesian;
|
||||||
|
origin (0.55863733 -0.300866705 0.00317260982);
|
||||||
|
e3 (0.42110287 0.02470132 -0.90667647);
|
||||||
|
e1 (0.90646036 0.02342535 0.42164069);
|
||||||
|
// STARCDRotation (-178.185897 -0.71772221 -155.059695);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -0,0 +1,235 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2008 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
|
||||||
|
|
||||||
|
Application
|
||||||
|
surfaceMeshCoordinateSystemTransform
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
Transform (scale/rotate/translate) a surface based on
|
||||||
|
a coordinateSystem.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
- surfaceMeshCoordinateSystemTransform inputFile outputFile [OPTION]
|
||||||
|
|
||||||
|
@param -clean \n
|
||||||
|
Perform some surface checking/cleanup on the input surface
|
||||||
|
|
||||||
|
@param -scale \<scale\> \n
|
||||||
|
Specify a scaling factor for writing the files
|
||||||
|
|
||||||
|
@param -triSurface \n
|
||||||
|
Use triSurface library for input/output
|
||||||
|
|
||||||
|
@param -dict \<dictionary\> \n
|
||||||
|
Specify an alternative dictionary for coordinateSystems.
|
||||||
|
|
||||||
|
Note
|
||||||
|
The filename extensions are used to determine the file format type.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "argList.H"
|
||||||
|
#include "timeSelector.H"
|
||||||
|
#include "Time.H"
|
||||||
|
|
||||||
|
#include "MeshedSurfaces.H"
|
||||||
|
#include "UnsortedMeshedSurfaces.H"
|
||||||
|
#include "coordinateSystems.H"
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
// Main program:
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::noParallel();
|
||||||
|
argList::validArgs.append("inputFile");
|
||||||
|
argList::validArgs.append("outputFile");
|
||||||
|
argList::validOptions.insert("scale", "scale");
|
||||||
|
argList::validOptions.insert("unsorted", "");
|
||||||
|
argList::validOptions.insert("from", "sourceCoordinateSystem");
|
||||||
|
argList::validOptions.insert("to", "targetCoordinateSystem");
|
||||||
|
argList::validOptions.insert("dict", "dictionary");
|
||||||
|
|
||||||
|
argList args(argc, argv);
|
||||||
|
Time runTime(args.rootPath(), args.caseName());
|
||||||
|
const stringList& params = args.additionalArgs();
|
||||||
|
|
||||||
|
word dictName("coordinateSystems");
|
||||||
|
fileName dictPath(runTime.constant());
|
||||||
|
fileName dictLocal;
|
||||||
|
|
||||||
|
if (args.options().found("dict"))
|
||||||
|
{
|
||||||
|
wordList elems(fileName(args.options()["dict"]).components());
|
||||||
|
dictName = elems[elems.size()-1];
|
||||||
|
dictPath = elems[0];
|
||||||
|
dictLocal = "";
|
||||||
|
|
||||||
|
if (elems.size() == 1)
|
||||||
|
{
|
||||||
|
dictPath = ".";
|
||||||
|
}
|
||||||
|
else if (elems.size() > 2)
|
||||||
|
{
|
||||||
|
dictLocal = fileName(SubList<word>(elems, elems.size()-2, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
autoPtr<coordinateSystem> fromCsys;
|
||||||
|
autoPtr<coordinateSystem> toCsys;
|
||||||
|
|
||||||
|
if (args.options().found("from") || args.options().found("to"))
|
||||||
|
{
|
||||||
|
IOobject csDictIo
|
||||||
|
(
|
||||||
|
dictName,
|
||||||
|
dictPath,
|
||||||
|
dictLocal,
|
||||||
|
runTime,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!csDictIo.headerOk())
|
||||||
|
{
|
||||||
|
FatalErrorIn(args.executable())
|
||||||
|
<< "Cannot open coordinateSystems file\n "
|
||||||
|
<< csDictIo.objectPath() << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
coordinateSystems csLst(csDictIo);
|
||||||
|
|
||||||
|
if (args.options().found("from"))
|
||||||
|
{
|
||||||
|
word csName(args.options()["from"]);
|
||||||
|
|
||||||
|
label csId = csLst.find(csName);
|
||||||
|
if (csId < 0)
|
||||||
|
{
|
||||||
|
FatalErrorIn(args.executable())
|
||||||
|
<< "Cannot find -from " << csName << nl
|
||||||
|
<< "available coordinateSystems: " << csLst.toc() << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
fromCsys.reset(new coordinateSystem(csLst[csId]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.options().found("to"))
|
||||||
|
{
|
||||||
|
word csName(args.options()["to"]);
|
||||||
|
|
||||||
|
label csId = csLst.find(csName);
|
||||||
|
if (csId < 0)
|
||||||
|
{
|
||||||
|
FatalErrorIn(args.executable())
|
||||||
|
<< "Cannot find -to " << csName << nl
|
||||||
|
<< "available coordinateSystems: " << csLst.toc() << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
toCsys.reset(new coordinateSystem(csLst[csId]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// maybe fix this later
|
||||||
|
if (fromCsys.valid() && toCsys.valid())
|
||||||
|
{
|
||||||
|
FatalErrorIn(args.executable())
|
||||||
|
<< "Only allowed -from or -to option at the moment."
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scalar scaleFactor = 0;
|
||||||
|
if (args.options().found("scale"))
|
||||||
|
{
|
||||||
|
IStringStream(args.options()["scale"])() >> scaleFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
fileName importName(params[0]);
|
||||||
|
fileName exportName(params[1]);
|
||||||
|
|
||||||
|
if (importName == exportName)
|
||||||
|
{
|
||||||
|
FatalErrorIn(args.executable())
|
||||||
|
<< "Output file " << exportName << " would overwrite input file."
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
!meshedSurface::canRead(importName.ext(), true)
|
||||||
|
|| !meshedSurface::canWrite(exportName.ext(), true)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
meshedSurface surf(importName);
|
||||||
|
|
||||||
|
if (args.options().found("clean"))
|
||||||
|
{
|
||||||
|
surf.cleanup(true);
|
||||||
|
surf.checkOrientation(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fromCsys.valid())
|
||||||
|
{
|
||||||
|
tmp<pointField> tpf = fromCsys().localPosition(surf.points());
|
||||||
|
surf.movePoints(tpf());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toCsys.valid())
|
||||||
|
{
|
||||||
|
tmp<pointField> tpf = toCsys().globalPosition(surf.points());
|
||||||
|
surf.movePoints(tpf());
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "writing " << exportName;
|
||||||
|
if (scaleFactor <= 0)
|
||||||
|
{
|
||||||
|
Info<< " without scaling" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< " with scaling " << scaleFactor << endl;
|
||||||
|
surf.scalePoints(scaleFactor);
|
||||||
|
}
|
||||||
|
surf.write(exportName);
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -117,23 +117,6 @@ private:
|
|||||||
//- Read OpenFOAM Surface format
|
//- Read OpenFOAM Surface format
|
||||||
bool read(Istream&);
|
bool read(Istream&);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// Protected Member functions
|
|
||||||
|
|
||||||
//- Return non-const access to global points
|
|
||||||
pointField& points()
|
|
||||||
{
|
|
||||||
return const_cast<pointField&>(ParentType::points());
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return non-const access to the faces
|
|
||||||
List<Face>& faces()
|
|
||||||
{
|
|
||||||
return static_cast<List<Face> &>(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
@ -308,12 +291,24 @@ public:
|
|||||||
return ParentType::points();
|
return ParentType::points();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Return non-const access to global points
|
||||||
|
pointField& points()
|
||||||
|
{
|
||||||
|
return const_cast<pointField&>(ParentType::points());
|
||||||
|
}
|
||||||
|
|
||||||
//- Return const access to the faces
|
//- Return const access to the faces
|
||||||
const List<Face>& faces() const
|
const List<Face>& faces() const
|
||||||
{
|
{
|
||||||
return static_cast<const List<Face> &>(*this);
|
return static_cast<const List<Face> &>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Return non-const access to the faces
|
||||||
|
List<Face>& faces()
|
||||||
|
{
|
||||||
|
return static_cast<List<Face> &>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
const surfGroupList& patches() const
|
const surfGroupList& patches() const
|
||||||
{
|
{
|
||||||
return patches_;
|
return patches_;
|
||||||
|
|||||||
@ -128,8 +128,6 @@ private:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Static protected functions
|
|
||||||
|
|
||||||
// Protected Member functions
|
// Protected Member functions
|
||||||
|
|
||||||
//- Sets default patch names based on the maximum patch number
|
//- Sets default patch names based on the maximum patch number
|
||||||
@ -148,24 +146,6 @@ protected:
|
|||||||
//- Sets patch names from hashed values (name -> id)
|
//- Sets patch names from hashed values (name -> id)
|
||||||
void setPatches(const HashTable<label>& groupToPatch);
|
void setPatches(const HashTable<label>& groupToPatch);
|
||||||
|
|
||||||
//- Return non-const access to global points
|
|
||||||
pointField& points()
|
|
||||||
{
|
|
||||||
return const_cast<pointField&>(ParentType::points());
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return non-const access to the faces
|
|
||||||
List<Face>& faces()
|
|
||||||
{
|
|
||||||
return static_cast<List<Face> &>(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return non-const access to the region Ids
|
|
||||||
List<label>& regions()
|
|
||||||
{
|
|
||||||
return regions_;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
@ -338,23 +318,43 @@ public:
|
|||||||
return ParentType::points();
|
return ParentType::points();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Return non-const access to global points
|
||||||
|
pointField& points()
|
||||||
|
{
|
||||||
|
return const_cast<pointField&>(ParentType::points());
|
||||||
|
}
|
||||||
|
|
||||||
//- Return const access to the faces
|
//- Return const access to the faces
|
||||||
const List<Face>& faces() const
|
const List<Face>& faces() const
|
||||||
{
|
{
|
||||||
return static_cast<const List<Face> &>(*this);
|
return static_cast<const List<Face> &>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Return non-const access to the faces
|
||||||
|
List<Face>& faces()
|
||||||
|
{
|
||||||
|
return static_cast<List<Face> &>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
//- Return const access to the regions
|
//- Return const access to the regions
|
||||||
const List<label>& regions() const
|
const List<label>& regions() const
|
||||||
{
|
{
|
||||||
return regions_;
|
return regions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Return non-const access to the region Ids
|
||||||
|
List<label>& regions()
|
||||||
|
{
|
||||||
|
return regions_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return const access to the patches
|
||||||
const surfPatchIdentifierList& patches() const
|
const surfPatchIdentifierList& patches() const
|
||||||
{
|
{
|
||||||
return patches_;
|
return patches_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Return non-const access to the patches
|
||||||
surfPatchIdentifierList& patches()
|
surfPatchIdentifierList& patches()
|
||||||
{
|
{
|
||||||
return patches_;
|
return patches_;
|
||||||
|
|||||||
Reference in New Issue
Block a user