Nektar++
Loading...
Searching...
No Matches
Functions | Variables
Nektar::MovementTests Namespace Reference

Functions

LibUtilities::SessionReaderSharedPtr CreateSession ()
 
SpatialDomains::ZoneBaseShPtr CreateZone (SpatialDomains::MovementType type, int zoneID, int domainID, LibUtilities::InterpreterSharedPtr interpreter)
 Produce dummy Zone objects, containing empty domain pointers.
 
SpatialDomains::InterfaceShPtr CreateInterface (int interfaceID, std::vector< int > compositeIDs)
 Produce dummy Interface objects, containing empty domain pointers.
 
 BOOST_AUTO_TEST_CASE (TestAddGetZones)
 
 BOOST_AUTO_TEST_CASE (TestAddGetInterfaces)
 
 BOOST_AUTO_TEST_CASE (TestWriteMovement)
 

Variables

const std::string angVelStr = "0.1*t"
 
std::vector< std::string > velocityStr = {"1.0", "2.0", "3.0"}
 
std::vector< std::string > displacementStr = {"1.0", "2.0", "3.0"}
 
const NekPoint< NekDoubleorigin = {1., 2., 3.}
 
const DNekVec axis = {1., 2., 3.}
 
const NekDouble rampTime = 1.0
 
const NekDouble sector = 0.0
 
const Array< OneD, NekDoublebase (3, 0.0)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/3]

Nektar::MovementTests::BOOST_AUTO_TEST_CASE ( TestAddGetInterfaces  )

Definition at line 150 of file TestMovement.cpp.

151{
154 interface2 = CreateInterface(1, {1, 2, 3}),
155 interface3 = CreateInterface(3, {4});
156 m.AddInterface("north", interface1, interface2);
157 m.AddInterface("east", interface2, interface3);
158 m.AddInterface("south", interface3, interface1);
159 SpatialDomains::InterfaceCollection interfaces = m.GetInterfaces();
160 BOOST_TEST(interfaces.size() == 3);
161 SpatialDomains::InterfacePairShPtr north = interfaces.at(
162 std::make_pair(0, "north")),
163 east = interfaces.at(
164 std::make_pair(1, "east")),
165 south = interfaces.at(
166 std::make_pair(2, "south"));
167 BOOST_TEST(north->m_leftInterface == interface1);
168 BOOST_TEST(north->m_rightInterface == interface2);
169 BOOST_TEST(east->m_leftInterface == interface2);
170 BOOST_TEST(east->m_rightInterface == interface3);
171 BOOST_TEST(south->m_leftInterface == interface3);
172 BOOST_TEST(south->m_rightInterface == interface1);
173}
const InterfaceCollection & GetInterfaces() const
Definition Movement.h:69
void AddInterface(std::string name, InterfaceShPtr left, InterfaceShPtr right)
Add pair of interfaces to this data.
SpatialDomains::InterfaceShPtr CreateInterface(int interfaceID, std::vector< int > compositeIDs)
Produce dummy Interface objects, containing empty domain pointers.
std::shared_ptr< Interface > InterfaceShPtr

References Nektar::SpatialDomains::Movement::AddInterface(), CreateInterface(), and Nektar::SpatialDomains::Movement::GetInterfaces().

◆ BOOST_AUTO_TEST_CASE() [2/3]

Nektar::MovementTests::BOOST_AUTO_TEST_CASE ( TestAddGetZones  )

Definition at line 129 of file TestMovement.cpp.

130{
135 SpatialDomains::MovementType::eFixed, 0,
136 0, interpreter),
137 zone2 = CreateZone(
138 SpatialDomains::MovementType::eRotate, 2,
139 2, interpreter);
140 m.AddZone(zone1);
141 m.AddZone(zone2);
142 std::map<int, SpatialDomains::ZoneBaseShPtr> zones = m.GetZones();
143 BOOST_TEST(zones.size() == 2);
144 BOOST_TEST(zones.at(0).get() == zone1.get());
145 BOOST_TEST(zones.at(2).get() == zone2.get());
146 BOOST_TEST(zones.at(0) == zone1);
147 BOOST_TEST(zones.at(2) == zone2);
148}
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
const std::map< int, ZoneBaseShPtr > & GetZones() const
Definition Movement.h:74
void AddZone(ZoneBaseShPtr zone)
Add a zone object to this Movement data.
std::shared_ptr< Interpreter > InterpreterSharedPtr
SpatialDomains::ZoneBaseShPtr CreateZone(SpatialDomains::MovementType type, int zoneID, int domainID, LibUtilities::InterpreterSharedPtr interpreter)
Produce dummy Zone objects, containing empty domain pointers.
std::shared_ptr< ZoneBase > ZoneBaseShPtr
Definition Zones.h:177

References Nektar::SpatialDomains::Movement::AddZone(), Nektar::MemoryManager< DataType >::AllocateSharedPtr(), CreateZone(), Nektar::SpatialDomains::eFixed, Nektar::SpatialDomains::eRotate, and Nektar::SpatialDomains::Movement::GetZones().

◆ BOOST_AUTO_TEST_CASE() [3/3]

Nektar::MovementTests::BOOST_AUTO_TEST_CASE ( TestWriteMovement  )

Definition at line 175 of file TestMovement.cpp.

176{
180 m.AddZone(
181 CreateZone(SpatialDomains::MovementType::eFixed, 0, 10, interpreter));
182 m.AddZone(CreateZone(SpatialDomains::MovementType::eTranslate, 3, 13,
183 interpreter));
184 m.AddZone(
185 CreateZone(SpatialDomains::MovementType::eRotate, 1, 11, interpreter));
186 m.AddInterface("north", CreateInterface(0, {0}),
187 CreateInterface(1, {1, 2, 3, 4}));
188 m.AddInterface("south", CreateInterface(2, {5, 6, 7, 8, 9, 11}),
189 CreateInterface(3, {12}));
190
191 SpatialDomains::InterfaceCollection interfaces = m.GetInterfaces();
192 std::map<int, SpatialDomains::ZoneBaseShPtr> zones = m.GetZones();
193 TiXmlElement *nektar = new TiXmlElement("NEKTAR");
195 TiXmlElement *movement = nektar->FirstChildElement("MOVEMENT");
196 BOOST_TEST(movement);
197 TiXmlElement *xmlZones = movement->FirstChildElement("ZONES"),
198 *xmlInterfaces = movement->FirstChildElement("INTERFACES");
199 BOOST_TEST(xmlZones);
200 BOOST_TEST(xmlInterfaces);
201
202 int id, err;
203 std::string attr;
204 std::vector<NekDouble> vec;
205
206 // Check the fixed zone
207 TiXmlElement *zone = xmlZones->FirstChildElement();
208 BOOST_TEST(zone->Value() == "F");
209 err = zone->QueryIntAttribute("ID", &id);
210 BOOST_TEST(err == TIXML_SUCCESS);
211 BOOST_TEST(id == 0);
212 err = zone->QueryStringAttribute("DOMAIN", &attr);
213 BOOST_TEST(err == TIXML_SUCCESS);
214 BOOST_TEST(attr == "D[10]");
215
216 // Check the rotating zone
217 zone = xmlZones->IterateChildren(zone)->ToElement();
218 BOOST_TEST(zone->Value() == "R");
219 err = zone->QueryIntAttribute("ID", &id);
220 BOOST_TEST(err == TIXML_SUCCESS);
221 BOOST_TEST(id == 1);
222 err = zone->QueryStringAttribute("DOMAIN", &attr);
223 BOOST_TEST(err == TIXML_SUCCESS);
224 BOOST_TEST(attr == "D[11]");
225 err = zone->QueryStringAttribute("ORIGIN", &attr);
226 BOOST_TEST(err == TIXML_SUCCESS);
227 ParseUtils::GenerateVector(attr, vec);
228 BOOST_TEST(NekPoint<NekDouble>(vec.at(0), vec.at(1), vec.at(2)) == origin);
229 err = zone->QueryStringAttribute("AXIS", &attr);
230 BOOST_TEST(err == TIXML_SUCCESS);
231 DNekVec xmlAxis(attr);
232 BOOST_TEST(xmlAxis.GetDimension() == 3);
233 for (int i = 0; i < 3; i++)
234 {
235 BOOST_TEST(xmlAxis[i] == axis[i]);
236 }
237 err = zone->QueryStringAttribute("ANGVEL", &attr);
238 BOOST_TEST(err == TIXML_SUCCESS);
239 BOOST_TEST(attr == angVelStr);
240
241 // Check the translating zone
242 zone = xmlZones->IterateChildren(zone)->ToElement();
243 BOOST_TEST(zone->Value() == "T");
244 err = zone->QueryIntAttribute("ID", &id);
245 BOOST_TEST(err == TIXML_SUCCESS);
246 BOOST_TEST(id == 3);
247 err = zone->QueryStringAttribute("DOMAIN", &attr);
248 BOOST_TEST(err == TIXML_SUCCESS);
249 BOOST_TEST(attr == "D[13]");
250 err = zone->QueryStringAttribute("XVELOCITY", &attr);
251 BOOST_TEST(err == TIXML_SUCCESS);
252 BOOST_TEST(attr == velocityStr[0]);
253 err = zone->QueryStringAttribute("YVELOCITY", &attr);
254 BOOST_TEST(err == TIXML_SUCCESS);
255 BOOST_TEST(attr == velocityStr[1]);
256 err = zone->QueryStringAttribute("ZVELOCITY", &attr);
257 BOOST_TEST(err == TIXML_SUCCESS);
258 BOOST_TEST(attr == velocityStr[2]);
259 err = zone->QueryStringAttribute("XDISPLACEMENT", &attr);
260 BOOST_TEST(err == TIXML_SUCCESS);
261 BOOST_TEST(attr == displacementStr[0]);
262 err = zone->QueryStringAttribute("YDISPLACEMENT", &attr);
263 BOOST_TEST(err == TIXML_SUCCESS);
264 BOOST_TEST(attr == displacementStr[1]);
265 err = zone->QueryStringAttribute("ZDISPLACEMENT", &attr);
266 BOOST_TEST(err == TIXML_SUCCESS);
267 BOOST_TEST(attr == displacementStr[2]);
268
269 BOOST_TEST(xmlZones->LastChild() == zone);
270
271 TiXmlElement *intr;
272
273 // Check the north interface
274 TiXmlElement *interface = xmlInterfaces->FirstChildElement();
275 BOOST_TEST(interface->Value() == "INTERFACE");
276 err = interface->QueryStringAttribute("NAME", &attr);
277 BOOST_TEST(err == TIXML_SUCCESS);
278 BOOST_TEST(attr == "north");
279 intr = interface->FirstChildElement();
280 BOOST_TEST(intr->Value() == "L");
281 err = intr->QueryIntAttribute("ID", &id);
282 BOOST_TEST(err == TIXML_SUCCESS);
283 BOOST_TEST(id == 0);
284 err = intr->QueryStringAttribute("BOUNDARY", &attr);
285 BOOST_TEST(err == TIXML_SUCCESS);
286 BOOST_TEST(attr == "C[0]");
287 intr = interface->IterateChildren(intr)->ToElement();
288 BOOST_TEST(intr->Value() == "R");
289 err = intr->QueryIntAttribute("ID", &id);
290 BOOST_TEST(err == TIXML_SUCCESS);
291 BOOST_TEST(id == 1);
292 err = intr->QueryStringAttribute("BOUNDARY", &attr);
293 BOOST_TEST(err == TIXML_SUCCESS);
294 BOOST_TEST(attr == "C[1-4]");
295
296 // Check the south interface
297 interface = xmlInterfaces->IterateChildren(interface)->ToElement();
298 BOOST_TEST(interface->Value() == "INTERFACE");
299 err = interface->QueryStringAttribute("NAME", &attr);
300 BOOST_TEST(err == TIXML_SUCCESS);
301 BOOST_TEST(attr == "south");
302 intr = interface->FirstChildElement();
303 BOOST_TEST(intr->Value() == "L");
304 err = intr->QueryIntAttribute("ID", &id);
305 BOOST_TEST(err == TIXML_SUCCESS);
306 BOOST_TEST(id == 2);
307 err = intr->QueryStringAttribute("BOUNDARY", &attr);
308 BOOST_TEST(err == TIXML_SUCCESS);
309 BOOST_TEST(attr == "C[5-9,11]");
310 intr = interface->IterateChildren(intr)->ToElement();
311 BOOST_TEST(intr->Value() == "R");
312 err = intr->QueryIntAttribute("ID", &id);
313 BOOST_TEST(err == TIXML_SUCCESS);
314 BOOST_TEST(id == 3);
315 err = intr->QueryStringAttribute("BOUNDARY", &attr);
316 BOOST_TEST(err == TIXML_SUCCESS);
317 BOOST_TEST(attr == "C[12]");
318
319 BOOST_TEST(xmlInterfaces->LastChild() == interface);
320
321 delete nektar;
322}
void WriteMovement(TiXmlElement *root)
Write the MOVEMENT section of the XML file.
NekVector< NekDouble > DNekVec

References Nektar::SpatialDomains::Movement::AddInterface(), Nektar::SpatialDomains::Movement::AddZone(), Nektar::MemoryManager< DataType >::AllocateSharedPtr(), angVelStr, axis, CreateInterface(), CreateZone(), displacementStr, Nektar::SpatialDomains::eFixed, Nektar::SpatialDomains::eRotate, Nektar::SpatialDomains::eTranslate, Nektar::ParseUtils::GenerateVector(), Nektar::NekVector< DataType >::GetDimension(), Nektar::SpatialDomains::Movement::GetInterfaces(), Nektar::SpatialDomains::Movement::GetZones(), origin, velocityStr, and Nektar::SpatialDomains::Movement::WriteMovement().

◆ CreateInterface()

SpatialDomains::InterfaceShPtr Nektar::MovementTests::CreateInterface ( int  interfaceID,
std::vector< int >  compositeIDs 
)

Produce dummy Interface objects, containing empty domain pointers.

Definition at line 115 of file TestMovement.cpp.

117{
119 for (auto &id : compositeIDs)
120 {
121 edge[id] =
123 }
126 interfaceID, edge, false));
127}
std::map< int, CompositeSharedPtr > CompositeMap
Definition MeshGraph.h:179

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ CreateSession()

LibUtilities::SessionReaderSharedPtr Nektar::MovementTests::CreateSession ( )

Definition at line 46 of file TestMovement.cpp.

47{
48 char arg = ' ';
49 char *args[] = {&arg};
50 return LibUtilities::SessionReader::CreateInstance(1, args);
51}

References Nektar::LibUtilities::SessionReader::CreateInstance().

◆ CreateZone()

SpatialDomains::ZoneBaseShPtr Nektar::MovementTests::CreateZone ( SpatialDomains::MovementType  type,
int  zoneID,
int  domainID,
LibUtilities::InterpreterSharedPtr  interpreter 
)

Produce dummy Zone objects, containing empty domain pointers.

Definition at line 63 of file TestMovement.cpp.

66{
68 switch (type)
69 {
70 case SpatialDomains::MovementType::eFixed:
71 {
74 zoneID, domainID, domain, 3));
75 }
76 break;
77 case SpatialDomains::MovementType::eRotate:
78 {
80 std::make_shared<LibUtilities::Equation>(interpreter,
81 angVelStr);
84 zoneID, domainID, domain, 3, origin, axis, angularVelEqn,
85 rampTime, sector, base));
86 }
87 break;
88 case SpatialDomains::MovementType::eTranslate:
89 {
90 Array<OneD, LibUtilities::EquationSharedPtr> velocityEqns(3);
91 Array<OneD, LibUtilities::EquationSharedPtr> displacementEqns(3);
92 for (int i = 0; i < 3; ++i)
93 {
94 velocityEqns[i] = std::make_shared<LibUtilities::Equation>(
95 interpreter, velocityStr[i]);
96 displacementEqns[i] = std::make_shared<LibUtilities::Equation>(
97 interpreter, displacementStr[i]);
98 }
99
100 return SpatialDomains::ZoneTranslateShPtr(
101 MemoryManager<SpatialDomains::ZoneTranslate>::AllocateSharedPtr(
102 zoneID, domainID, domain, 3, velocityEqns,
103 displacementEqns));
104 }
105 break;
106 default:
107 {
108 }
109 break;
110 }
111 return nullptr;
112}
std::shared_ptr< Equation > EquationSharedPtr
Definition Equation.h:131
std::shared_ptr< ZoneRotate > ZoneRotateShPtr
Definition Zones.h:375
std::shared_ptr< ZoneFixed > ZoneFixedShPtr
Definition Zones.h:377

References angVelStr, axis, base, displacementStr, Nektar::SpatialDomains::eFixed, Nektar::SpatialDomains::eRotate, Nektar::SpatialDomains::eTranslate, origin, rampTime, sector, and velocityStr.

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

Variable Documentation

◆ angVelStr

const std::string Nektar::MovementTests::angVelStr = "0.1*t"

Definition at line 53 of file TestMovement.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and CreateZone().

◆ axis

const DNekVec Nektar::MovementTests::axis = {1., 2., 3.}

Definition at line 58 of file TestMovement.cpp.

58{1., 2., 3.};

Referenced by BOOST_AUTO_TEST_CASE(), and CreateZone().

◆ base

const Array< OneD, NekDouble > Nektar::MovementTests::base(3, 0.0) ( ,
0.  0 
)

Referenced by CreateZone().

◆ displacementStr

std::vector<std::string> Nektar::MovementTests::displacementStr = {"1.0", "2.0", "3.0"}

Definition at line 56 of file TestMovement.cpp.

56{"1.0", "2.0", "3.0"};

Referenced by BOOST_AUTO_TEST_CASE(), and CreateZone().

◆ origin

const NekPoint<NekDouble> Nektar::MovementTests::origin = {1., 2., 3.}

Definition at line 57 of file TestMovement.cpp.

57{1., 2., 3.};

Referenced by BOOST_AUTO_TEST_CASE(), and CreateZone().

◆ rampTime

const NekDouble Nektar::MovementTests::rampTime = 1.0

Definition at line 59 of file TestMovement.cpp.

Referenced by CreateZone().

◆ sector

const NekDouble Nektar::MovementTests::sector = 0.0

Definition at line 60 of file TestMovement.cpp.

Referenced by CreateZone().

◆ velocityStr

std::vector<std::string> Nektar::MovementTests::velocityStr = {"1.0", "2.0", "3.0"}

Definition at line 55 of file TestMovement.cpp.

55{"1.0", "2.0", "3.0"};

Referenced by BOOST_AUTO_TEST_CASE(), and CreateZone().