Nektar++
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
39#include <boost/core/ignore_unused.hpp>
40
43
45
46namespace Nektar
47{
48namespace FieldUtils
49{
50
54 "Extract Boundary field");
55
57 : ProcessModule(f)
58{
59 // set up dafault values.
60 m_config["bnd"] = ConfigOption(false, "All", "Boundary to be processed");
61 m_config["addnormals"] = ConfigOption(true, "0", "Add normals to output");
62
63 f->m_writeBndFld = true;
64 f->m_declareExpansionAsContField = true;
65 f->m_requireBoundaryExpansion = true;
66}
67
69{
70}
71
72void ProcessBoundaryExtract::v_Process(po::variables_map &vm)
73{
74 m_f->SetUpExp(vm);
75
76 m_f->m_addNormals = m_config["addnormals"].as<bool>();
77
78 // Set up Field options to output boundary fld
79 string bvalues = m_config["bnd"].as<string>();
80
81 vector<unsigned int> bndRegions;
82 if (boost::iequals(bvalues, "All"))
83 {
84 int numBndExp = 0;
85
87 m_f->m_exp[0]->GetGraph());
90
91 for (auto &breg_it : bregions)
92 {
93 numBndExp = max(numBndExp, breg_it.first);
94 }
95 // assuming all boundary regions are consecutive number if
96 // regions is one more than maximum id
97 numBndExp++;
98
99 // not all partitions in parallel touch all boundaries so
100 // find maximum number of boundaries
101 m_f->m_comm->GetSpaceComm()->AllReduce(numBndExp,
103
104 // THis presumes boundary regions are numbered consecutively
105 for (int i = 0; i < numBndExp; ++i)
106 {
107 bndRegions.push_back(i);
108 }
109 }
110 else
111 {
112 ASSERTL0(ParseUtils::GenerateVector(bvalues, bndRegions),
113 "Failed to interpret bnd values string");
114 }
115
116 if (m_f->m_bndRegionsToWrite.size())
117 {
118 // This was already called. Just check if the bnd option is the same
119 ASSERTL0(m_f->m_bndRegionsToWrite == bndRegions,
120 "Incompatible bnd parameters.");
121 }
122 else
123 {
124 m_f->m_bndRegionsToWrite = bndRegions;
125
126 if (m_f->m_exp[0]->GetNumElmts() != 0)
127 {
128 for (int i = 0; i < m_f->m_exp.size(); ++i)
129 {
130 m_f->m_exp[i]->FillBndCondFromField(m_f->m_exp[i]->GetCoeffs());
131 }
132 }
133 }
134}
135} // namespace FieldUtils
136} // namespace Nektar
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
FieldSharedPtr m_f
Field object.
Definition: Module.h:234
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition: Module.h:263
virtual 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:292
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:198
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
Definition: ParseUtils.cpp:131
const BoundaryRegionCollection & GetBoundaryRegions(void) const
Definition: Conditions.h:234
std::shared_ptr< Field > FieldSharedPtr
Definition: Field.hpp:991
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:317
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:49
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
Definition: Conditions.h:210
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
Represents a command-line configuration option.
Definition: Module.h:131