Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 namespace Nektar
42 {
44  {
45  typedef Loki::SingletonHolder<StimulusFactory,
46  Loki::CreateUsingNew,
47  Loki::NoDestroy > Type;
48  return Type::Instance();
49  }
50 
51  /**
52  * @class Stimulus
53  *
54  * The Stimulus class and derived classes implement a range of stimuli.
55  * The stimulus contains input stimuli that can be applied throughout the
56  * domain, on specified regions determined by the derived classes of
57  * Stimulus, at specified frequencies determined by the derived classes of
58  * Protocol.
59  *
60  */
61 
62  /**
63  * Stimulus base class constructor.
64  */
66  const MultiRegions::ExpListSharedPtr& pField,
67  const TiXmlElement* pXml)
68  {
69  m_session = pSession;
70  m_field = pField;
71  m_nq = pField->GetTotPoints();
72 
73  const TiXmlElement* vProtocol = pXml->FirstChildElement("PROTOCOL");
74  string vTypeP = vProtocol->Attribute("TYPE");
75 
77  vTypeP, pSession, vProtocol);
78 
79  }
80 
81 
82  /**
83  * Initialise the stimulus. Allocate workspace and variable storage.
84  */
86  {
87  }
88 
89 
90  /**
91  *
92  */
93  vector<StimulusSharedPtr> Stimulus::LoadStimuli(
95  const MultiRegions::ExpListSharedPtr& pField)
96  {
97  vector<StimulusSharedPtr> vStimList;
98 
99  TiXmlElement* vStimuli = pSession->GetElement("Nektar/Stimuli");
100  if (vStimuli)
101  {
102  TiXmlElement* vStimulus = vStimuli->FirstChildElement("STIMULUS");
103  while (vStimulus)
104  {
105  string vType = vStimulus->Attribute("TYPE");
106 
107  vStimList.push_back(GetStimulusFactory().CreateInstance(
108  vType, pSession, pField, vStimulus));
109  vStimulus = vStimulus->NextSiblingElement("STIMULUS");
110  }
111  }
112  return vStimList;
113  }
114 }
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
ProtocolSharedPtr m_Protocol
Stimulus protocol to apply.
Definition: Stimulus.h:99
ProtocolFactory & GetProtocolFactory()
Definition: Protocol.cpp:40
LibUtilities::SessionReaderSharedPtr m_session
Session.
Definition: Stimulus.h:93
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
int m_nq
Number of physical points.
Definition: Stimulus.h:97
static std::vector< StimulusSharedPtr > LoadStimuli(const LibUtilities::SessionReaderSharedPtr &pSession, const MultiRegions::ExpListSharedPtr &pField)
Definition: Stimulus.cpp:93
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
Stimulus(const LibUtilities::SessionReaderSharedPtr &pSession, const MultiRegions::ExpListSharedPtr &pField, const TiXmlElement *pXml)
Definition: Stimulus.cpp:65
void Initialise()
Initialise the stimulus storage and set initial conditions.
Definition: Stimulus.cpp:85
MultiRegions::ExpListSharedPtr m_field
Transmembrane potential field from PDE system.
Definition: Stimulus.h:95
StimulusFactory & GetStimulusFactory()
Definition: Stimulus.cpp:43
Provides a generic Factory class.
Definition: NekFactory.hpp:116