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

#include <InputFld.h>

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

Public Member Functions

 InputFld (FieldSharedPtr f)
 Set up InputFld object. More...
 
virtual ~InputFld ()
 
virtual void Process (po::variables_map &vm)
 
- Public Member Functions inherited from Nektar::Utilities::InputModule
 InputModule (FieldSharedPtr p_m)
 
void AddFile (string fileType, string fileName)
 
 InputModule (MeshSharedPtr p_m)
 
void OpenStream ()
 Open a file for input. More...
 
- Public Member Functions inherited from Nektar::Utilities::Module
 Module (FieldSharedPtr p_f)
 
void RegisterConfig (string key, string value)
 Register a configuration option with a module. More...
 
void PrintConfig ()
 Print out all configuration options for a module. More...
 
void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
bool GetRequireEquiSpaced (void)
 
void SetRequireEquiSpaced (bool pVal)
 
void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 
 Module (MeshSharedPtr p_m)
 
virtual void Process ()=0
 
void RegisterConfig (string key, string value)
 
void PrintConfig ()
 
void SetDefaults ()
 
MeshSharedPtr GetMesh ()
 
virtual void ProcessVertices ()
 Extract element vertices. More...
 
virtual void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual void ProcessElements ()
 Generate element IDs. More...
 
virtual void ProcessComposites ()
 Generate composites. More...
 
virtual void ClearElementLinks ()
 

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::Utilities::InputModule
void PrintSummary ()
 Print summary of elements. More...
 
void PrintSummary ()
 Print summary of elements. More...
 
- Protected Member Functions inherited from Nektar::Utilities::Module
 Module ()
 
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
void PrismLines (int prism, PerMap &perFaces, set< int > &prismsDone, vector< ElementSharedPtr > &line)
 
- Protected Attributes inherited from Nektar::Utilities::InputModule
set< string > m_allowedFiles
 
std::ifstream m_mshFile
 Input stream. More...
 
- Protected Attributes inherited from Nektar::Utilities::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 
MeshSharedPtr m_mesh
 Mesh object. More...
 

Detailed Description

Converter for Fld files.

Definition at line 49 of file InputFld.h.

Constructor & Destructor Documentation

Nektar::Utilities::InputFld::InputFld ( FieldSharedPtr  f)

Set up InputFld object.

Definition at line 71 of file InputFld.cpp.

References Nektar::Utilities::InputModule::m_allowedFiles.

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

Definition at line 83 of file InputFld.cpp.

84 {
85 }

Member Function Documentation

static ModuleSharedPtr Nektar::Utilities::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.
void Nektar::Utilities::InputFld::Process ( po::variables_map &  vm)
virtual

Implements Nektar::Utilities::Module.

Definition at line 91 of file InputFld.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::LibUtilities::NekFactory< tKey, tBase, >::CreateInstance(), Nektar::LibUtilities::GetCommFactory(), Nektar::Utilities::Module::m_f, Nektar::Timer::Start(), Nektar::Timer::Stop(), and Nektar::Timer::TimePerTest().

92 {
93  Timer timer;
94 
95  if(m_f->m_verbose)
96  {
97  if(m_f->m_comm->GetRank() == 0)
98  {
99  cout << "Processing input fld file" << endl;
100  timer.Start();
101  }
102  }
103 
104  int i,j;
105  string fldending;
106  //Determine appropriate field input
107  if(m_f->m_inputfiles.count("fld") != 0)
108  {
109  fldending = "fld";
110  }
111  else if(m_f->m_inputfiles.count("chk") != 0)
112  {
113  fldending = "chk";
114  }
115  else if (m_f->m_inputfiles.count("rst") != 0)
116  {
117  fldending = "rst";
118  }
119  else if (m_f->m_inputfiles.count("bse") != 0)
120  {
121  fldending = "bse";
122  }
123  else
124  {
125  ASSERTL0(false,"no input file found");
126  }
127 
128  if(!m_f->m_fld)
129  {
130  if(m_f->m_session)
131  {
133  ::AllocateSharedPtr(m_f->m_session->GetComm());
134  }
135  else // serial communicator
136  {
140  }
141  }
142 
143 
144  if(m_f->m_graph) // all for restricted expansion defintion when loading field
145  {
146  // currently load all field (possibly could read data from expansion list
147  // but it is re-arranged in expansion)
148 
149  const SpatialDomains::ExpansionMap &expansions = m_f->m_graph->GetExpansions();
150 
151  // if Range has been speficied it is possible to have a
152  // partition which is empty so check this and return if
153  // no elements present.
154 
155  if(!expansions.size())
156  {
157  return;
158  }
159 
160  m_f->m_exp.resize(1);
161 
162  Array<OneD,int> ElementGIDs(expansions.size());
163  SpatialDomains::ExpansionMap::const_iterator expIt;
164 
165  i = 0;
166  for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
167  {
168  ElementGIDs[i++] = expIt->second->m_geomShPtr->GetGlobalID();
169  }
170 
171  m_f->m_fielddef.clear();
172  m_f->m_data.clear();
173 
174  m_f->m_fld->Import(m_f->m_inputfiles[fldending][0],
175  m_f->m_fielddef,
176  m_f->m_data,
177  m_f->m_fieldMetaDataMap,
178  ElementGIDs);
179  }
180  else // load all data.
181  {
182  m_f->m_fld->Import(m_f->m_inputfiles[fldending][0],
183  m_f->m_fielddef,
184  m_f->m_data,
185  m_f->m_fieldMetaDataMap);
186  }
187 
188 
189  // if m_exp defined presume we want to load all field into expansions
190  if(m_f->m_exp.size())
191  {
192  int nfields,nstrips;
193 
194  m_f->m_session->LoadParameter("Strip_Z",nstrips,1);
195 
196  if(vm.count("useSessionVariables"))
197  {
198  nfields = m_f->m_session->GetVariables().size();
199  }
200  else
201  {
202  nfields = m_f->m_fielddef[0]->m_fields.size();
203  }
204 
205 
206  m_f->m_exp.resize(nfields*nstrips);
207 
208  vector<string> vars = m_f->m_session->GetVariables();
209 
210 
211  // declare other fields;
212  for (int s = 0; s < nstrips; ++s) //homogeneous strip varient
213  {
214  for (i = 0; i < nfields; ++i)
215  {
216  if(i < vars.size())
217  {
218  // check to see if field already defined
219  if(!m_f->m_exp[s*nfields+i])
220  {
221  m_f->m_exp[s*nfields+i] = m_f->AppendExpList(
222  m_f->m_fielddef[0]->m_numHomogeneousDir,
223  vars[i]);
224  }
225  }
226  else
227  {
228  if(vars.size())
229  {
230  m_f->m_exp[s*nfields+i] =
231  m_f->AppendExpList(
232  m_f->m_fielddef[0]->m_numHomogeneousDir,
233  vars[0]);
234  }
235  else
236  {
237  m_f->m_exp[s*nfields+i] =
238  m_f->AppendExpList(
239  m_f->m_fielddef[0]->m_numHomogeneousDir);
240  }
241  }
242  }
243  }
244 
245  // Extract data to coeffs and bwd transform
246  for(int s = 0; s < nstrips; ++s) //homogeneous strip varient
247  {
248  for (j = 0; j < nfields; ++j)
249  {
250  for (i = 0; i < m_f->m_data.size()/nstrips; ++i)
251  {
252  m_f->m_exp[s*nfields+j]->
253  ExtractDataToCoeffs(m_f->m_fielddef[i*nstrips+s],
254  m_f->m_data[i*nstrips+s],
255  m_f->m_fielddef[i*nstrips+s]
256  ->m_fields[j],
257  m_f->m_exp[s*nfields+j]->UpdateCoeffs());
258  }
259  m_f->m_exp[s*nfields+j]->BwdTrans(m_f->m_exp[s*nfields+j]->GetCoeffs(),
260  m_f->m_exp[s*nfields+j]->UpdatePhys());
261  }
262  }
263 
264  // if range is defined reset up output field in case of
265  // reducing fld definition
266  if(vm.count("range"))
267  {
268  std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
269  = m_f->m_exp[0]->GetFieldDefinitions();
270  std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
271 
272  for (j = 0; j < nfields; ++j)
273  {
274  for (i = 0; i < FieldDef.size(); ++i)
275  {
276  FieldDef[i]->m_fields.push_back(m_f->m_fielddef[0]->m_fields[j]);
277  m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
278  }
279  }
280  m_f->m_fielddef = FieldDef;
281  m_f->m_data = FieldData;
282  }
283  }
284 
285  if(m_f->m_verbose)
286  {
287  if(m_f->m_comm->GetRank() == 0)
288  {
289  timer.Stop();
290  NekDouble cpuTime = timer.TimePerTest(1);
291 
292  stringstream ss;
293  ss << cpuTime << "s";
294  cout << "InputFld CPU Time: " << setw(8) << left
295  << ss.str() << endl;
296  cpuTime = 0.0;
297  }
298 
299  }
300 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:162
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
CommFactory & GetCommFactory()
Definition: Comm.cpp:64
FieldSharedPtr m_f
Field object.
void Stop()
Definition: Timer.cpp:62
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:53
double NekDouble
void Start()
Definition: Timer.cpp:51
NekDouble TimePerTest(unsigned int n)
Returns amount of seconds per iteration in a test with n iterations.
Definition: Timer.cpp:108
std::map< int, ExpansionShPtr > ExpansionMap
Definition: MeshGraph.h:174

Member Data Documentation

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

ModuleKey for class.

Definition at line 62 of file InputFld.h.