Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::FieldUtils::InputFld Class Reference

#include <InputFld.h>

Inheritance diagram for Nektar::FieldUtils::InputFld:
Inheritance graph
[legend]
Collaboration diagram for Nektar::FieldUtils::InputFld:
Collaboration graph
[legend]

Public Member Functions

 InputFld (FieldSharedPtr f)
 Set up InputFld object. More...
 
virtual ~InputFld ()
 
virtual void Process (po::variables_map &vm)
 
virtual std::string GetModuleName ()
 
- Public Member Functions inherited from Nektar::FieldUtils::InputModule
 InputModule (FieldSharedPtr p_m)
 
FIELD_UTILS_EXPORT void AddFile (string fileType, string fileName)
 
- Public Member Functions inherited from Nektar::FieldUtils::Module
FIELD_UTILS_EXPORT Module (FieldSharedPtr p_f)
 
FIELD_UTILS_EXPORT void RegisterConfig (string key, string value)
 Register a configuration option with a module. More...
 
FIELD_UTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
FIELD_UTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
FIELD_UTILS_EXPORT bool GetRequireEquiSpaced (void)
 
FIELD_UTILS_EXPORT void SetRequireEquiSpaced (bool pVal)
 
FIELD_UTILS_EXPORT void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 

Static Public Member Functions

static ModuleSharedPtr create (FieldSharedPtr f)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey m_className []
 ModuleKey for class. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::FieldUtils::InputModule
void PrintSummary ()
 Print summary of elements. More...
 
- Protected Member Functions inherited from Nektar::FieldUtils::Module
 Module ()
 
- Protected Attributes inherited from Nektar::FieldUtils::InputModule
set< string > m_allowedFiles
 
- Protected Attributes inherited from Nektar::FieldUtils::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 

Detailed Description

Converter for Fld files.

Definition at line 49 of file InputFld.h.

Constructor & Destructor Documentation

Nektar::FieldUtils::InputFld::InputFld ( FieldSharedPtr  f)

Set up InputFld object.

Definition at line 69 of file InputFld.cpp.

References Nektar::FieldUtils::InputModule::m_allowedFiles.

69  : InputModule(f)
70 {
71  m_allowedFiles.insert("fld");
72  m_allowedFiles.insert("chk");
73  m_allowedFiles.insert("rst");
74  m_allowedFiles.insert("bse");
75 }
Nektar::FieldUtils::InputFld::~InputFld ( )
virtual

Definition at line 80 of file InputFld.cpp.

81 {
82 }

Member Function Documentation

static ModuleSharedPtr Nektar::FieldUtils::InputFld::create ( FieldSharedPtr  f)
inlinestatic

Creates an instance of this class.

Definition at line 57 of file InputFld.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

58  {
60  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
virtual std::string Nektar::FieldUtils::InputFld::GetModuleName ( )
inlinevirtual

Implements Nektar::FieldUtils::Module.

Definition at line 64 of file InputFld.h.

65  {
66  return "InputFld";
67  }
void Nektar::FieldUtils::InputFld::Process ( po::variables_map &  vm)
virtual

Implements Nektar::FieldUtils::Module.

Definition at line 87 of file InputFld.cpp.

References ASSERTL0, and Nektar::FieldUtils::Module::m_f.

88 {
89 
90  if (m_f->m_verbose)
91  {
92  if (m_f->m_comm->TreatAsRankZero())
93  {
94  cout << "Processing input fld file" << endl;
95  }
96  }
97 
98  int i, j;
99  string fldending;
100  // Determine appropriate field input
101  if (m_f->m_inputfiles.count("fld") != 0)
102  {
103  fldending = "fld";
104  }
105  else if (m_f->m_inputfiles.count("chk") != 0)
106  {
107  fldending = "chk";
108  }
109  else if (m_f->m_inputfiles.count("rst") != 0)
110  {
111  fldending = "rst";
112  }
113  else if (m_f->m_inputfiles.count("bse") != 0)
114  {
115  fldending = "bse";
116  }
117  else
118  {
119  ASSERTL0(false, "no input file found");
120  }
121 
122  if(m_f->m_graph)
123  {
124  if (m_f->m_data.size() == 0)
125  {
126  // currently load all field (possibly could read data from
127  // expansion list but it is re-arranged in expansion)
128 
129  const SpatialDomains::ExpansionMap &expansions =
130  m_f->m_graph->GetExpansions();
131 
132  // if Range has been speficied it is possible to have a
133  // partition which is empty so check this and return if
134  // no elements present.
135 
136  if (!expansions.size())
137  {
138  return;
139  }
140 
141  m_f->m_exp.resize(1);
142 
143  Array<OneD, int> ElementGIDs(expansions.size());
144  SpatialDomains::ExpansionMap::const_iterator expIt;
145 
146  i = 0;
147  for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
148  {
149  ElementGIDs[i++] = expIt->second->m_geomShPtr->GetGlobalID();
150  }
151 
152  m_f->m_fielddef.clear();
153  m_f->m_data.clear();
154 
155  m_f->FieldIOForFile(m_f->m_inputfiles[fldending][0])->Import(
156  m_f->m_inputfiles[fldending][0], m_f->m_fielddef, m_f->m_data,
157  m_f->m_fieldMetaDataMap, ElementGIDs);
158  }
159  }
160  else // load all data.
161  {
162  m_f->FieldIOForFile(m_f->m_inputfiles[fldending][0])->Import(
163  m_f->m_inputfiles[fldending][0], m_f->m_fielddef, m_f->m_data,
164  m_f->m_fieldMetaDataMap);
165  }
166 
167  // if m_exp defined presume we want to load all field into expansions
168  if (m_f->m_exp.size())
169  {
170  int nfields, nstrips;
171 
172  m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
173 
174  if (vm.count("useSessionVariables"))
175  {
176  nfields = m_f->m_session->GetVariables().size();
177  }
178  else
179  {
180  nfields = m_f->m_fielddef[0]->m_fields.size();
181  }
182 
183  m_f->m_exp.resize(nfields * nstrips);
184 
185  vector<string> vars = m_f->m_session->GetVariables();
186 
187  // declare other fields;
188  for (int s = 0; s < nstrips; ++s) // homogeneous strip varient
189  {
190  for (i = 0; i < nfields; ++i)
191  {
192  if (i < vars.size())
193  {
194  // check to see if field already defined
195  if (!m_f->m_exp[s * nfields + i])
196  {
197  m_f->m_exp[s * nfields + i] = m_f->AppendExpList(
198  m_f->m_fielddef[0]->m_numHomogeneousDir, vars[i]);
199  }
200  }
201  else
202  {
203  if (vars.size())
204  {
205  m_f->m_exp[s * nfields + i] = m_f->AppendExpList(
206  m_f->m_fielddef[0]->m_numHomogeneousDir, vars[0]);
207  }
208  else
209  {
210  m_f->m_exp[s * nfields + i] = m_f->AppendExpList(
211  m_f->m_fielddef[0]->m_numHomogeneousDir);
212  }
213  }
214  }
215  }
216 
217  // Extract data to coeffs and bwd transform
218  for (int s = 0; s < nstrips; ++s) // homogeneous strip varient
219  {
220  for (j = 0; j < nfields; ++j)
221  {
222  for (i = 0; i < m_f->m_data.size() / nstrips; ++i)
223  {
224  m_f->m_exp[s * nfields + j]->ExtractDataToCoeffs(
225  m_f->m_fielddef[i * nstrips + s],
226  m_f->m_data[i * nstrips + s],
227  m_f->m_fielddef[i * nstrips + s]->m_fields[j],
228  m_f->m_exp[s * nfields + j]->UpdateCoeffs());
229  }
230  m_f->m_exp[s * nfields + j]->BwdTrans(
231  m_f->m_exp[s * nfields + j]->GetCoeffs(),
232  m_f->m_exp[s * nfields + j]->UpdatePhys());
233  }
234  }
235 
236  // reset output field in case Import loaded elements that are not
237  // in the expansion (because of range option of partitioning)
238  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
239  m_f->m_exp[0]->GetFieldDefinitions();
240  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
241 
242  for (j = 0; j < nfields; ++j)
243  {
244  for (i = 0; i < FieldDef.size(); ++i)
245  {
246  FieldDef[i]->m_fields.push_back(
247  m_f->m_fielddef[0]->m_fields[j]);
248  m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
249  }
250  }
251  m_f->m_fielddef = FieldDef;
252  m_f->m_data = FieldData;
253  }
254 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
std::map< int, ExpansionShPtr > ExpansionMap
Definition: MeshGraph.h:174
FieldSharedPtr m_f
Field object.

Member Data Documentation

ModuleKey Nektar::FieldUtils::InputFld::m_className
static
Initial value:

ModuleKey for class.

Definition at line 62 of file InputFld.h.