Nektar++
Stimulus.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File Stimulus.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: Stimulus base class.
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <tinyxml.h>
37 
39 
40 using namespace std;
41 
42 namespace Nektar
43 {
45  {
46  static StimulusFactory instance;
47  return instance;
48  }
49 
50  /**
51  * @class Stimulus
52  *
53  * The Stimulus class and derived classes implement a range of stimuli.
54  * The stimulus contains input stimuli that can be applied throughout the
55  * domain, on specified regions determined by the derived classes of
56  * Stimulus, at specified frequencies determined by the derived classes of
57  * Protocol.
58  *
59  */
60 
61  /**
62  * Stimulus base class constructor.
63  */
64  Stimulus::Stimulus(const LibUtilities::SessionReaderSharedPtr& pSession,
65  const MultiRegions::ExpListSharedPtr& pField,
66  const TiXmlElement* pXml)
67  {
68  m_session = pSession;
69  m_field = pField;
70  m_nq = pField->GetTotPoints();
71 
72  const TiXmlElement* vProtocol = pXml->FirstChildElement("PROTOCOL");
73  string vTypeP = vProtocol->Attribute("TYPE");
74 
75  m_Protocol = GetProtocolFactory().CreateInstance(
76  vTypeP, pSession, vProtocol);
77 
78  }
79 
80 
81  /**
82  * Initialise the stimulus. Allocate workspace and variable storage.
83  */
84  void Stimulus::Initialise()
85  {
86  }
87 
88 
89  /**
90  *
91  */
92  vector<StimulusSharedPtr> Stimulus::LoadStimuli(
94  const MultiRegions::ExpListSharedPtr& pField)
95  {
96  vector<StimulusSharedPtr> vStimList;
97 
98  TiXmlElement* vStimuli = pSession->GetElement("Nektar/Stimuli");
99  if (vStimuli)
100  {
101  TiXmlElement* vStimulus = vStimuli->FirstChildElement("STIMULUS");
102  while (vStimulus)
103  {
104  string vType = vStimulus->Attribute("TYPE");
105 
106  vStimList.push_back(GetStimulusFactory().CreateInstance(
107  vType, pSession, pField, vStimulus));
108  vStimulus = vStimulus->NextSiblingElement("STIMULUS");
109  }
110  }
111  return vStimList;
112  }
113 }
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
ProtocolFactory & GetProtocolFactory()
Definition: Protocol.cpp:39
STL namespace.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:144
StimulusFactory & GetStimulusFactory()
Definition: Stimulus.cpp:44
std::shared_ptr< SessionReader > SessionReaderSharedPtr
Provides a generic Factory class.
Definition: NekFactory.hpp:103