The Conley-Morse Graphs Software
procshape.h
Go to the documentation of this file.
1/////////////////////////////////////////////////////////////////////////////
2///
3/// @file procshape.h
4///
5/// A plug-in for post-processing of Morse decompositions
6/// which saves the real exit sets of all the Morse sets
7/// and also makes some shape analysis of the computed sets.
8/// This is a replacement for "procmdec.h".
9///
10/// @author Pawel Pilarczyk
11///
12/////////////////////////////////////////////////////////////////////////////
13
14// Copyright (C) 1997-2014 by Pawel Pilarczyk.
15//
16// This file is part of my research software package. This is free software:
17// you can redistribute it and/or modify it under the terms of the GNU
18// General Public License as published by the Free Software Foundation,
19// either version 3 of the License, or (at your option) any later version.
20//
21// This software is distributed in the hope that it will be useful,
22// but WITHOUT ANY WARRANTY; without even the implied warranty of
23// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24// GNU General Public License for more details.
25//
26// You should have received a copy of the GNU General Public License
27// along with this software; see the file "license.txt". If not,
28// please, see <https://www.gnu.org/licenses/>.
29
30// Started on October 27, 2010. Last revision: April 28, 2011.
31
32
33#ifndef _CMGRAPHS_PROCSHAPE_H_
34#define _CMGRAPHS_PROCSHAPE_H_
35
36// include some standard C++ header files
37#include <sstream>
38#include <fstream>
39#include <string>
40
41// include selected header files from the CHomP library
42#include "chomp/system/textfile.h"
43#include "chomp/system/timeused.h"
44#include "chomp/struct/digraph.h"
45#include "chomp/struct/flatmatr.h"
46#include "chomp/struct/multitab.h"
47#include "chomp/cubes/neighbor.h"
48
49// include local header files
50#include "config.h"
51#include "typedefs.h"
52#include "conindex.h"
53#include "morsedec.h"
54#include "typedyns.h"
55#include "utils.h"
56
57
58namespace custom {
59
60/// Post-processing of Morse decompositions by means of cycle decomposition.
61namespace procMorseDecShape {
62
63/// Computes the boundary of a set of cubes.
64template <class CubSetType>
65void computeBoundary (const CubSetType &X, CubSetType &bd)
66{
67 using namespace chomp::homology;
68
69 if (X. empty ())
70 return;
71
72 int_t maxNeighbors = getmaxneighbors (X [0]. dim ());
73 int_t size = X. size ();
74 for (int_t n = 0; n < size; ++ n)
75 {
76 if (getneighbors (X [n], static_cast<BitField *> (0),
77 X, static_cast<CubSetType *> (0), 0) !=
78 maxNeighbors)
79 {
80 bd. add (X [n]);
81 }
82 }
83
84 return;
85} /* computeBoundary */
86
87
88// --------------------------------------------------
89// ------- post-process a Morse decomposition -------
90// --------------------------------------------------
91
92/// Post-processes a Morse decomposition by computing a decomposition
93/// of each Morse set into cycle sets and analyzing this decomposition.
94template <class CubSetType, class MorseDecType, class GraphType,
95 class CubMapType>
96inline void processMorseDec (const MorseDecType &morseDec,
97 const CubSetType &allCubes, const GraphType &g,
98 const CubMapType &theCubMap, const CubMapType &,
99 const std::string &cubesFilePrefix,
100 const std::string &procFilePrefix)
101{
102 using namespace chomp::homology;
103
104 sout << "===== Post-processing the Morse sets. =====\n";
105 timeused timePostProc;
106 timePostProc = 0;
107
108 // analyze each Morse set
109 int nSets = morseDec. count ();
110 for (int n = 0; n < nSets; ++ n)
111 {
112 const CubSetType &morseCubes = morseDec [n];
113 int_t morseCount = morseCubes. size ();
114
115 // restrict the analysis to the given Morse set
116 sbug << "Morse set no. " << n << ": " <<
117 morseCount << " cubes.\n";
118
119 // compute the real exit set for the Morse set
120 sbug << "Exit set: ";
121 CubSetType exitSet;
122 for (int i = 0; i < morseCount; ++ i)
123 theCubMap (morseCubes [i], &exitSet, 0, 0, false);
124 exitSet. remove (morseCubes);
125 sbug << exitSet. size () << " cubes.\n";
126
127 // save the exit set to a file if requested to
128 if (!cubesFilePrefix. empty ())
129 {
130 // prepare a file name for this set
131 std::ostringstream exitFileNameStr;
132 exitFileNameStr << cubesFilePrefix << n << "e.cub";
133 std::string exitFileName = exitFileNameStr. str ();
134
135 // save the exit set to a file
136 sbug << "Saving the exit set to '" <<
137 exitFileName << "'... ";
138 std::ofstream f (exitFileName. c_str ());
139 f << "; The exit set for the corresponding Morse "
140 "set (" << exitSet. size () << " cubes).\n";
141 f << exitSet;
142 f. close ();
143 sbug << "Done.\n";
144 }
145
146 // compute the boundary of the exit set
147 sbug << "Computing the boundary of the exit set... ";
148 CubSetType exitSetBd;
149 computeBoundary (exitSet, exitSetBd);
150 sbug << exitSetBd. size () << " cubes.\n";
151 if (!exitSetBd. empty ())
152 {
153 sbug << "Exit set bounding box: ";
154 CoordMinMax rangeExit;
155 rangeExit (exitSetBd);
156 sbug << rangeExit << ".\n";
157 }
158
159 // save the boundary of the exit set if necessary
160 if (!cubesFilePrefix. empty ())
161 {
162 // prepare a file name for this set
163 std::ostringstream exitBdFileNameStr;
164 exitBdFileNameStr << cubesFilePrefix << n <<
165 "eb.cub";
166 std::string exitBdFileName =
167 exitBdFileNameStr. str ();
168
169 // save the computed boundary to a file
170 sbug << "Saving this boundary to '" <<
171 exitBdFileName << "'... ";
172 std::ofstream f (exitBdFileName. c_str ());
173 f << "; The boundary of the exit set "
174 "for the corresponding Morse set (" <<
175 exitSetBd. size () << " cubes).\n";
176 f << exitSet;
177 f. close ();
178 sbug << "Done.\n";
179 }
180
181 // compute the boundary of the Morse set
182 sbug << "Computing the boundary of the Morse set... ";
183 CubSetType morseBoundary;
184 computeBoundary (morseCubes, morseBoundary);
185 sbug << morseBoundary. size () << " cubes.\n";
186 sbug << "Morse set bounding box: ";
187 CoordMinMax rangeSet;
188 rangeSet (morseBoundary);
189 sbug << rangeSet << ".\n";
190
191 // save the boundary of the Morse set if necessary
192 if (!cubesFilePrefix. empty ())
193 {
194 // prepare a file name for this set
195 std::ostringstream bdFileNameStr;
196 bdFileNameStr << cubesFilePrefix << n << "b.cub";
197 std::string bdFileName = bdFileNameStr. str ();
198
199 // save the computed boundary to a file
200 sbug << "Saving this boundary to '" <<
201 bdFileName << "'... ";
202 std::ofstream f (bdFileName. c_str ());
203 f << "; The boundary of the Morse set (" <<
204 morseBoundary. size () << " cubes).\n";
205 f << morseBoundary;
206 f. close ();
207 sbug << "Done.\n";
208 }
209
210 // compute the maximal distance from the boundary
211 // and do some other post-processing if necessary
212 // TODO
213 }
214
215 sout << "===== Post-processing completed in " << timePostProc <<
216 ". =====\n";
217
218 return;
219} /* processMorseDec */
220
221
222} // namespace procMorseDecShape
223} // namespace custom
224
225
226#endif // _CMGRAPHS_PROCSHAPE_H_
227
A class whose objects store, update and show coordinate ranges.
Definition: utils.h:444
Choice of configuration settings.
Conley index computation routines.
Morse decompositions.
void processMorseDec(const MorseDecType &morseDec, const CubSetType &allCubes, const GraphType &g, const CubMapType &theCubMap, const CubMapType &, const std::string &cubesFilePrefix, const std::string &procFilePrefix)
Post-processes a Morse decomposition by computing a decomposition of each Morse set into cycle sets a...
Definition: procshape.h:96
void computeBoundary(const CubSetType &X, CubSetType &bd)
Computes the boundary of a set of cubes.
Definition: procshape.h:65
Customizable settings that are supposed to be modified and/or chosen by the user of the software.
Customizable data types for the Conley-Morse graphs computation program.
Data types for the dynamical systems data structures.
Utilites and helper functions.