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
36#include <tinyxml.h>
37
39
40using namespace std;
41
42namespace 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 */
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
76 GetProtocolFactory().CreateInstance(vTypeP, pSession, vProtocol);
77}
78
79/**
80 * Initialise the stimulus. Allocate workspace and variable storage.
81 */
83{
84}
85
86/**
87 *
88 */
89vector<StimulusSharedPtr> Stimulus::LoadStimuli(
92{
93 vector<StimulusSharedPtr> vStimList;
94
95 TiXmlElement *vStimuli = pSession->GetElement("Nektar/Stimuli");
96 if (vStimuli)
97 {
98 TiXmlElement *vStimulus = vStimuli->FirstChildElement("STIMULUS");
99 while (vStimulus)
100 {
101 string vType = vStimulus->Attribute("TYPE");
102
103 vStimList.push_back(GetStimulusFactory().CreateInstance(
104 vType, pSession, pField, vStimulus));
105 vStimulus = vStimulus->NextSiblingElement("STIMULUS");
106 }
107 }
108 return vStimList;
109}
110} // namespace Nektar
Provides a generic Factory class.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Stimulus(const LibUtilities::SessionReaderSharedPtr &pSession, const MultiRegions::ExpListSharedPtr &pField, const TiXmlElement *pXml)
Definition: Stimulus.cpp:64
void Initialise()
Initialise the stimulus storage and set initial conditions.
Definition: Stimulus.cpp:82
static std::vector< StimulusSharedPtr > LoadStimuli(const LibUtilities::SessionReaderSharedPtr &pSession, const MultiRegions::ExpListSharedPtr &pField)
Definition: Stimulus.cpp:89
MultiRegions::ExpListSharedPtr m_field
Transmembrane potential field from PDE system.
Definition: Stimulus.h:95
ProtocolSharedPtr m_Protocol
Stimulus protocol to apply.
Definition: Stimulus.h:99
int m_nq
Number of physical points.
Definition: Stimulus.h:97
LibUtilities::SessionReaderSharedPtr m_session
Session.
Definition: Stimulus.h:93
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
ProtocolFactory & GetProtocolFactory()
Definition: Protocol.cpp:39
StimulusFactory & GetStimulusFactory()
Definition: Stimulus.cpp:44
STL namespace.