Nektar++
Loading...
Searching...
No Matches
TestOptimization.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: TestOptimization.hpp
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:
32//
33///////////////////////////////////////////////////////////////////////////////
34
38
39using namespace Nektar;
40using namespace Nektar::LibUtilities;
41using namespace Nektar::MultiRegions;
42
44{
45public:
47 {
48 meshName = "run/optimization.xml";
49 }
50
52 {
53 BOOST_TEST_MESSAGE("teardown fixture");
54 }
55
56 void Configure(const std::string &execSpace)
57 {
58 BOOST_TEST_MESSAGE("Creating input and output fields");
59
60 // Construct a fake command-line argument array to be fed to
61 // Session::Reader::CreateInstance. The first element stands for
62 // the name of the executable which, in our case, doesn't matter.
63 int argc = 3;
64 char **argv = new char *[argc];
65 argv[0] = strdup("exe_name");
66 argv[1] = strdup(meshName.data());
67 argv[2] = strdup(("--opExecSpace=" + execSpace).c_str());
68
70 session->InitSession();
71
72 for (int i = 0; i < argc; ++i)
73 {
74 free(argv[i]);
75 }
76 delete[] argv;
77 }
78
79 void Configure(const std::string &execSpace, const std::string &impl)
80 {
81 BOOST_TEST_MESSAGE("Creating input and output fields");
82
83 // Construct a fake command-line argument array to be fed to
84 // Session::Reader::CreateInstance. The first element stands for
85 // the name of the executable which, in our case, doesn't matter.
86 int argc = 4;
87 char **argv = new char *[argc];
88 argv[0] = strdup("exe_name");
89 argv[1] = meshName.data();
90 argv[2] = strdup(("--opExecSpace=" + execSpace).c_str());
91 argv[3] = strdup(("--opImpl=" + impl).c_str());
92
94 session->InitSession();
95
96 delete[] argv;
97 }
98
99 /// The mesh with every element at @p nmodes orthogonal modes, so that a
100 /// test sets the expansion order the default implementation follows.
101 /// The orthogonal basis is the one that admits a single mode (order 0).
103 {
104 return ExpansionList(nmodes, nmodes);
105 }
106
107 /// The mesh with its first half of elements (composite C[0]) at
108 /// @p nmodesFirst orthogonal modes and its second half at
109 /// @p nmodesSecond, so that a test can give the two blocks different
110 /// orders.
112 const int nmodesSecond)
113 {
116 for (const auto &expInfo : graph->GetExpansionInfo("u"))
117 {
118 expInfo.second->m_basisKeyVector =
120 expInfo.second->m_geomPtr, SpatialDomains::eOrthogonal,
121 expInfo.first < 5 ? nmodesFirst : nmodesSecond);
122 }
124 session, graph, true, "u");
125 }
126
127protected:
128 std::string meshName = "";
130};
Whole-field base class and factory machinery shared by every element-operator family in the MultiRegi...
Whole-field operator base class and factory machinery shared by every operator family in the MultiReg...
SpatialDomains::MeshGraphSharedPtr graph
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
static LibUtilities::BasisKeyVector DefineBasisKeyFromExpansionType(Geometry *in, ExpansionType type, const int order, const int numpoints=-1)
The basis keys of expansion type type at order on in, with numpoints quadrature points in every direc...
static MeshGraphSharedPtr Read(const LibUtilities::SessionReaderSharedPtr pSession, LibUtilities::DomainRangeShPtr rng=LibUtilities::NullDomainRangeShPtr, bool fillGraph=true, SpatialDomains::MeshGraphSharedPtr partitionedGraph=nullptr)
LibUtilities::SessionReaderSharedPtr session
void Configure(const std::string &execSpace)
MultiRegions::ExpListSharedPtr ExpansionList(const int nmodes)
The mesh with every element at nmodes orthogonal modes, so that a test sets the expansion order the d...
MultiRegions::ExpListSharedPtr ExpansionList(const int nmodesFirst, const int nmodesSecond)
The mesh with its first half of elements (composite C[0]) at nmodesFirst orthogonal modes and its sec...
void Configure(const std::string &execSpace, const std::string &impl)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition MeshGraph.h:287