Nektar++
Loading...
Searching...
No Matches
ProcessBoundaryExtract.cpp
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////////////
2//
3// File: ProcessBoundaryExtract.cpp
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: Set up boundary to be extracted when writing fld file.
32//
33////////////////////////////////////////////////////////////////////////////////
34
35#include <iostream>
36#include <string>
37using namespace std;
38
41
43
44namespace Nektar::FieldUtils
45{
46
50 "Extract Boundary field");
51
53 : ProcessModule(f)
54{
55 // set up dafault values.
56 m_config["bnd"] = ConfigOption(false, "All", "Boundary to be processed");
57 m_config["addnormals"] = ConfigOption(true, "0", "Add normals to output");
58
59 f->m_writeBndFld = true;
60 f->m_declareExpansionAsContField = true;
61 f->m_requireBoundaryExpansion = true;
62}
63
67
68void ProcessBoundaryExtract::v_Process(po::variables_map &vm)
69{
70 m_f->m_addNormals = m_config["addnormals"].as<bool>();
71
72 // Set up Field options to output boundary fld
73 string bvalues = m_config["bnd"].as<string>();
74
75 vector<unsigned int> bndRegions;
76 SpatialDomains::BoundaryConditions bcs(m_f->m_session, m_f->m_graph);
77
78 if (boost::iequals(bvalues, "All"))
79 {
80 int numBndExp = 0;
81
84
85 for (auto &breg_it : bregions)
86 {
87 numBndExp = max(numBndExp, breg_it.first);
88 }
89 // assuming all boundary regions are consecutive number if
90 // regions is one more than maximum id
91 numBndExp++;
92
93 // not all partitions in parallel touch all boundaries so
94 // find maximum number of boundaries
95 m_f->m_comm->GetSpaceComm()->AllReduce(numBndExp,
97
98 // This presumes boundary regions are numbered consecutively
99 for (int i = 0; i < numBndExp; ++i)
100 {
101 bndRegions.push_back(i);
102 }
103 }
104 else
105 {
106 // set a tag for use when generating explist.
107 m_f->m_session->SetTag("CreateBndRegions", bvalues);
108 ASSERTL0(ParseUtils::GenerateVector(bvalues, bndRegions),
109 "Failed to interpret bnd values string");
110 }
111
112 // if GlobalSysSoln is set to DirectMultiLevelStaticCond, reset it
113 // to IterativeStaticCond to stop multilevel static condensation
114 // processing and assocuated calls to partioner which may cause issues
115 if (m_f->m_session->DefinesSolverInfo("GlobalSysSoln"))
116 {
117 if (m_f->m_session->MatchSolverInfo("GlobalSysSoln",
118 "DirectMultiLevelStaticCond"))
119 {
120 m_f->m_session->SetSolverInfo("GlobalSysSoln",
121 "IterativeStaticCond");
123 "Resetting GlobalSySoln to IterativeStaticCond");
124 }
125 }
126
127 m_f->SetUpExp(vm);
128
129 if (m_f->m_bndRegionsToWrite.size())
130 {
131 // This was already called. Just check if the bnd option is the same
132 ASSERTL0(m_f->m_bndRegionsToWrite == bndRegions,
133 "Incompatible bnd parameters.");
134 }
135 else
136 {
137 m_f->m_bndRegionsToWrite = bndRegions;
138 }
139
140 if (m_f->m_exp[0]->GetNumElmts() != 0)
141 {
142 for (int i = 0; i < m_f->m_exp.size(); ++i)
143 {
144 m_f->m_exp[i]->FillBndCondFromField(m_f->m_exp[i]->GetCoeffs());
145 }
146 }
147}
148} // namespace Nektar::FieldUtils
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
FieldSharedPtr m_f
Field object.
Definition Module.h:239
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition Module.h:272
void v_Process(po::variables_map &vm) override
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
Abstract base class for processing modules.
Definition Module.h:301
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
const BoundaryRegionCollection & GetBoundaryRegions(void) const
Definition Conditions.h:273
std::shared_ptr< Field > FieldSharedPtr
Definition Field.hpp:1026
std::pair< ModuleType, std::string > ModuleKey
Definition Module.h:180
ModuleFactory & GetModuleFactory()
Definition Module.cpp:47
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
Definition Conditions.h:249
STL namespace.
scalarT< T > max(scalarT< T > lhs, scalarT< T > rhs)
Definition scalar.hpp:305
Represents a command-line configuration option.
Definition Module.h:129