makeGraph.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 #include "writeFile.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 void makeGraph
48 (
49  const scalarField& x,
50  const volScalarField& vsf,
51  const word& graphFormat
52 )
53 {
54  makeGraph(x, vsf, vsf.name(), graphFormat);
55 }
56 
57 
58 void makeGraph
59 (
60  const scalarField& x,
61  const volScalarField& vsf,
62  const word& name,
63  const word& graphFormat
64 )
65 {
67  (
68  vsf.rootPath()
69  /vsf.caseName()
71  /"graphs"
72  /vsf.instance()
73  );
74  mkDir(path);
75 
76  makeGraph
77  (
78  x,
79  vsf.primitiveField(),
80  name,
81  path,
83  );
84 }
85 
86 
87 void makeGraph
88 (
89  const scalarField& x,
90  const scalarField& sf,
91  const word& name,
92  const fileName& path,
93  const word& graphFormat
94 )
95 {
96  graph
97  (
98  name,
99  "x",
100  name,
101  x,
102  sf
103  ).write(path/name, graphFormat);
104 }
105 
106 
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108 
109 } // End namespace Foam
110 
111 // ************************************************************************* //
const word & name() const
Return name.
Definition: IOobject.H:295
A class for handling file names.
Definition: fileName.H:79
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:45
word graphFormat
Definition: createFields.H:34
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
Generic GeometricField class.
Class to create, store and output qgraph files.
Definition: graph.H:58
Pre-declare SubField and related Field type.
Definition: Field.H:56
static const word outputPrefix
Directory prefix.
Definition: writeFile.H:72
A class for handling words, derived from string.
Definition: word.H:59
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:290
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
const fileName & rootPath() const
Definition: IOobject.C:384
const fileName & instance() const
Definition: IOobject.H:378
const fileName & caseName() const
Definition: IOobject.C:366
Namespace for OpenFOAM.
fileName path(UMean.rootPath()/UMean.caseName()/functionObjects::writeFile::outputPrefix/"graphs"/UMean.instance())