makeGraph.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Global
25  makeGraph
26 
27 Description
28  Write a graph file for a field given the data point locations field,
29  the field of interest and the name of the field to be used for the
30  graph file name.
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #include "makeGraph.H"
35 #include "volFields.H"
36 #include "fvMesh.H"
37 #include "graph.H"
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 namespace Foam
42 {
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 void makeGraph
47 (
48  const scalarField& x,
49  const volScalarField& vsf,
50  const word& graphFormat
51 )
52 {
53  makeGraph(x, vsf, vsf.name(), graphFormat);
54 }
55 
56 
57 void makeGraph
58 (
59  const scalarField& x,
60  const volScalarField& vsf,
61  const word& name,
62  const word& graphFormat
63 )
64 {
65  fileName path(vsf.rootPath()/vsf.caseName()/"graphs"/vsf.instance());
66  mkDir(path);
67 
68  makeGraph
69  (
70  x,
71  vsf.primitiveField(),
72  name,
73  path,
75  );
76 }
77 
78 
79 void makeGraph
80 (
81  const scalarField& x,
82  const scalarField& sf,
83  const word& name,
84  const fileName& path,
85  const word& graphFormat
86 )
87 {
88  graph
89  (
90  name,
91  "x",
92  name,
93  x,
94  sf
95  ).write(path/name, graphFormat);
96 }
97 
98 
99 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 
101 } // End namespace Foam
102 
103 // ************************************************************************* //
const word & name() const
Return name.
Definition: IOobject.H:291
A class for handling file names.
Definition: fileName.H:69
void write(Ostream &, const word &format) const
Write graph to stream in given format.
Definition: graph.C:221
void makeGraph(const scalarField &x, const volScalarField &vsf, const word &graphFormat)
Definition: makeGraph.C:44
word graphFormat
Definition: createFields.H:34
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
Class to create, store and output qgraph files.
Definition: graph.H:58
A class for handling words, derived from string.
Definition: word.H:59
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
volScalarField sf(fieldObject, mesh)
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Definition: POSIX.C:297
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
const fileName & rootPath() const
Definition: IOobject.C:379
const fileName & instance() const
Definition: IOobject.H:386
const fileName & caseName() const
Definition: IOobject.C:343
Namespace for OpenFOAM.