Nektar++
InputFld.cpp
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////////////
2//
3// File: InputFld.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: Reads a Nektar++ FLD file.
32//
33////////////////////////////////////////////////////////////////////////////////
34
35#include <iostream>
36#include <string>
37using namespace std;
38
39#include <boost/core/ignore_unused.hpp>
40
41#include "InputFld.h"
42using namespace Nektar;
43
44namespace Nektar
45{
46namespace FieldUtils
47{
48
51 ModuleKey(eInputModule, "fld"), InputFld::create, "Reads Fld file."),
54 "Reads checkpoint file."),
57 "Reads restart file."),
60 "Reads stability base-flow file.")};
61
62/**
63 * @brief Set up InputFld object.
64 *
65 */
67{
68 m_allowedFiles.insert("fld");
69 m_allowedFiles.insert("chk");
70 m_allowedFiles.insert("rst");
71 m_allowedFiles.insert("bse");
72}
73
74/**
75 *
76 */
78{
79}
80
81/**
82 *
83 */
84void InputFld::v_Process(po::variables_map &vm)
85{
86 boost::ignore_unused(vm);
87
88 int i;
89 string fileName = m_config["infile"].as<string>();
90
91 LibUtilities::FieldIOSharedPtr fld = m_f->FieldIOForFile(fileName);
92
93 int oldSize = m_f->m_fielddef.size();
94 if (m_f->m_graph)
95 {
96 // Determine IDs of elements in the domain
97 vector<int> IDs;
98 auto domain = m_f->m_graph->GetDomain();
99 for (int d = 0; d < domain.size(); ++d)
100 {
101 for (auto &compIter : domain[d])
102 {
103 for (auto &x : compIter.second->m_geomVec)
104 {
105 IDs.push_back(x->GetGlobalID());
106 }
107 }
108 }
109
110 if (!IDs.size())
111 {
112 return;
113 }
114
115 // Move to an array to match FieldIO interface
116 Array<OneD, int> ElementGIDs(IDs.size(), IDs.data());
117
118 fld->Import(fileName, m_f->m_fielddef, m_f->m_data,
119 m_f->m_fieldMetaDataMap, ElementGIDs);
120 }
121 else // load all data.
122 {
123 fld->Import(fileName, m_f->m_fielddef, m_f->m_data,
124 m_f->m_fieldMetaDataMap);
125 }
126
127 // save field names
128 for (i = 0; i < m_f->m_fielddef[oldSize]->m_fields.size(); ++i)
129 {
130 // check for multiple fld files
131 auto it = find(m_f->m_variables.begin(), m_f->m_variables.end(),
132 m_f->m_fielddef[oldSize]->m_fields[i]);
133
134 if (it == m_f->m_variables.end())
135 {
136 m_f->m_variables.push_back(m_f->m_fielddef[oldSize]->m_fields[i]);
137 }
138 }
139}
140} // namespace FieldUtils
141} // namespace Nektar
InputFld(FieldSharedPtr f)
Set up InputFld object.
Definition: InputFld.cpp:66
static ModuleKey m_className[]
ModuleKey for class.
Definition: InputFld.h:60
static ModuleSharedPtr create(FieldSharedPtr f)
Creates an instance of this class.
Definition: InputFld.h:55
virtual void v_Process(po::variables_map &vm) override
Definition: InputFld.cpp:84
Abstract base class for input modules.
Definition: Module.h:278
std::set< std::string > m_allowedFiles
List of allowed file formats.
Definition: Module.h:265
FieldSharedPtr m_f
Field object.
Definition: Module.h:234
std::map< std::string, ConfigOption > m_config
List of configuration values.
Definition: Module.h:263
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:198
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::shared_ptr< FieldIO > FieldIOSharedPtr
Definition: FieldIO.h:327
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Definition: StdRegions.hpp:453
std::vector< double > d(NPUPPER *NPUPPER)
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2