Nektar++
Loading...
Searching...
No Matches
CompositeNames.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: CompositeNames.h
4//
5// For more information, please see: http://www.nektar.info/
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Resolution of composite names in composite lists.
32// other I/O routiens in SpatialDomains
33//
34////////////////////////////////////////////////////////////////////////////////
35#ifndef NEKTAR_SPATIALDOMAINS_COMPOSITENAMES_H
36#define NEKTAR_SPATIALDOMAINS_COMPOSITENAMES_H
37
39
40#include <map>
41#include <string>
42#include <vector>
43
45{
46
47/**
48 * @brief Expand the body of a composite list into composite IDs, resolving
49 * any entry that is a name rather than a number.
50 *
51 * @p str is what stands between the brackets of a `C[...]`: a comma-separated
52 * list whose entries are a number, a `first-last` range of numbers, or the
53 * name of a composite. So `0-3,7`, `WALL` and `0-3,WALL,INLET` are all
54 * accepted, and a name may contain spaces since only commas separate entries.
55 *
56 * A numeric entry is always read as an ID, so a composite that happens to be
57 * named "3" never shadows the composite whose ID is 3; this keeps every list
58 * that could be written before names existed meaning exactly what it did.
59 * Names are matched exactly, including case, because a label comes from the
60 * mesh rather than from Nektar++ and folding it would be guessing. Where
61 * several composites carry one name -- which is how a mesh says two sets of
62 * faces are one patch -- the name yields all of them.
63 *
64 * Entries that are neither a number nor a known name are appended to
65 * @p unresolved rather than failing here, since whether an unknown name is an
66 * error depends on the caller: on one partition of a mesh a name may
67 * legitimately refer to nothing local.
68 *
69 * @param str Body of the composite list.
70 * @param labels Composite ID to name, as MeshGraph holds it.
71 * @param ids Resolved composite IDs, appended in the order listed.
72 * @param unresolved Entries that resolved to nothing, appended.
73 *
74 * @return True if every entry resolved and there was at least one; false
75 * otherwise, including for a list that is empty or all separators.
76 */
77/**
78 * @brief Make a name read out of a mesh file usable as a composite label.
79 *
80 * Mesh formats are more permissive about names than the places a label has to
81 * survive: it becomes an XML attribute, and it is meant to be referable from a
82 * composite list, where a comma separates one entry from the next and brackets
83 * delimit the list. A name containing any of those could never be written down
84 * or referred to, so they are dropped along with surrounding whitespace.
85 * Spaces within a name are kept, since a list can carry those.
86 */
88 const std::string &name);
89
91 const std::string &str, const std::map<int, std::string> &labels,
92 std::vector<unsigned int> &ids,
93 std::vector<std::string> *unresolved = nullptr);
94
95} // namespace Nektar::SpatialDomains
96
97#endif
#define SPATIAL_DOMAINS_EXPORT
bool ParseCompositeList(const std::string &str, const std::map< int, std::string > &labels, std::vector< unsigned int > &ids, std::vector< std::string > *unresolved)
std::string SanitiseCompositeName(const std::string &name)
Expand the body of a composite list into composite IDs, resolving any entry that is a name rather tha...