1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Reads an foam mesh and writes a CSC/Elmer .nodes/.elements/.boundary format.
31 - foamMeshToElmer [OPTION] \n
32 Reads an foam mesh and writes a CSC/Elmer .nodes/.elements/.boundary format.
34 @param -scale \<factor\>\n
35 Specify an alternative geometry scaling factor.
39 The cellTable information available in the files
40 @c constant/cellTable and @c constant/polyMesh/cellTableId
41 will be used if available. Otherwise the cellZones are used when
42 creating the cellTable information.
45 Foam::cellTable, Foam::meshWriter and Foam::meshWriters::Elmer
47 \*---------------------------------------------------------------------------*/
50 #include "timeSelector.H"
51 #include "objectRegistry.H"
54 #include "ElmerMeshWriter.H"
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 int main(int argc, char *argv[])
63 argList::noParallel();
64 timeSelector::addOptions();
66 argList::validOptions.insert("scale", "factor");
67 argList::validOptions.insert("exclude", "pattern");
69 # include "setRootCase.H"
70 # include "createTime.H"
72 instantList timeDirs = timeSelector::select0(runTime, args);
75 // default: do not rescale
76 scalar scaleFactor = 1;
77 if (args.optionReadIfPresent("scale", scaleFactor))
85 wordRe excludePattern;
86 args.optionReadIfPresent("exclude", excludePattern);
87 Info<<"Exclude pattern: \"" << excludePattern << "\"." <<endl;
88 excludePattern.compile(wordRe::DETECT_NOCASE);
90 # include "createPolyMesh.H"
93 forAll(timeDirs, timeI)
95 runTime.setTime(timeDirs[timeI], timeI);
97 # include "getTimeIndex.H"
99 polyMesh::readUpdateState state = mesh.readUpdate();
101 if (!timeI || state != polyMesh::UNCHANGED)
103 meshWriters::Elmer writer(mesh, excludePattern, scaleFactor);
104 fileName dirName("elmerMesh");
105 if (state != polyMesh::UNCHANGED)
107 dirName += '_' + runTime.timeName();
110 if (!writer.write(dirName))
112 break; // Conversion failed
119 Info << "End\n" << endl;
124 // ************************************************************************* //