Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Stimulus base class.
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #include <tinyxml.h>
38 
40 
41 using namespace std;
42 
43 namespace Nektar
44 {
46  {
47  typedef Loki::SingletonHolder<StimulusFactory,
48  Loki::CreateUsingNew,
49  Loki::NoDestroy > Type;
50  return Type::Instance();
51  }
52 
53  /**
54  * @class Stimulus
55  *
56  * The Stimulus class and derived classes implement a range of stimuli.
57  * The stimulus contains input stimuli that can be applied throughout the
58  * domain, on specified regions determined by the derived classes of
59  * Stimulus, at specified frequencies determined by the derived classes of
60  * Protocol.
61  *
62  */
63 
64  /**
65  * Stimulus base class constructor.
66  */
67  Stimulus::Stimulus(const LibUtilities::SessionReaderSharedPtr& pSession,
68  const MultiRegions::ExpListSharedPtr& pField,
69  const TiXmlElement* pXml)
70  {
71  m_session = pSession;
72  m_field = pField;
73  m_nq = pField->GetTotPoints();
74 
75  const TiXmlElement* vProtocol = pXml->FirstChildElement("PROTOCOL");
76  string vTypeP = vProtocol->Attribute("TYPE");
77 
78  m_Protocol = GetProtocolFactory().CreateInstance(
79  vTypeP, pSession, vProtocol);
80 
81  }
82 
83 
84  /**
85  * Initialise the stimulus. Allocate workspace and variable storage.
86  */
87  void Stimulus::Initialise()
88  {
89  }
90 
91 
92  /**
93  *
94  */
95  vector<StimulusSharedPtr> Stimulus::LoadStimuli(
97  const MultiRegions::ExpListSharedPtr& pField)
98  {
99  vector<StimulusSharedPtr> vStimList;
100 
101  TiXmlElement* vStimuli = pSession->GetElement("Nektar/Stimuli");
102  if (vStimuli)
103  {
104  TiXmlElement* vStimulus = vStimuli->FirstChildElement("STIMULUS");
105  while (vStimulus)
106  {
107  string vType = vStimulus->Attribute("TYPE");
108 
109  vStimList.push_back(GetStimulusFactory().CreateInstance(
110  vType, pSession, pField, vStimulus));
111  vStimulus = vStimulus->NextSiblingElement("STIMULUS");
112  }
113  }
114  return vStimList;
115  }
116 }
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
ProtocolFactory & GetProtocolFactory()
Definition: Protocol.cpp:40
STL namespace.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
boost::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
LibUtilities::NekFactory< std::string, Stimulus, const LibUtilities::SessionReaderSharedPtr &, const MultiRegions::ExpListSharedPtr &, const TiXmlElement * > StimulusFactory
Datatype of the NekFactory used to instantiate classes derived from the EquationSystem class...
Definition: Stimulus.h:60
StimulusFactory & GetStimulusFactory()
Definition: Stimulus.cpp:45
Provides a generic Factory class.
Definition: NekFactory.hpp:116