preCICE v3.2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
QuickTest.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <string>
5#include <vector>
7#include "testing/Testing.hpp"
8
9namespace precice::testing {
10
11struct QuickTest {
12
13 struct Mesh {
15 };
16
17 struct ReadData {
19 };
20
21 struct WriteData {
23 };
24
29
34
39
41 {
42 auto n = pos.size() / interface.getMeshDimensions(meshName);
43 vertexIDs.resize(n, -1);
45 return *this;
46 }
47
49 {
51 return *this;
52 }
53
55 {
56 BOOST_TEST_MESSAGE("Remeshing");
58 return *this;
59 }
60
62 {
64 return *this;
65 }
66
68 {
70 return *this;
71 }
72
73 void finalize()
74 {
76 }
77
79 {
81 return *this;
82 }
83
84 QuickTest &advance(double dt)
85 {
87 return *this;
88 }
89
91 {
93 return *this;
94 }
95
102
110
112 {
113 auto data = read();
114 BOOST_TEST(data == expected, boost::test_tools::per_element());
115 return *this;
116 }
117
119 {
120 auto data = read();
122 BOOST_TEST(data == expected, boost::test_tools::per_element());
123 return *this;
124 }
125
127 {
130 return *this;
131 }
132
134 {
137 return *this;
138 }
139
141 {
142 BOOST_TEST(!interface.isCouplingOngoing());
143 return *this;
144 }
145
151};
152
153inline QuickTest::Mesh operator""_mesh(const char *name, std::size_t)
154{
155 return {name};
156}
157
158inline QuickTest::ReadData operator""_read(const char *name, std::size_t)
159{
160 return {name};
161}
162
163inline QuickTest::WriteData operator""_write(const char *name, std::size_t)
164{
165 return {name};
166}
167
168} // namespace precice::testing
std::string name
Main Application Programming Interface of preCICE. Include using #include <precice/precice....
int getDataDimensions(::precice::string_view meshName, ::precice::string_view dataName) const
Returns the spatial dimensionality of the given data on the given mesh.
bool isCouplingOngoing() const
Checks if the coupled simulation is still ongoing.
void finalize()
Finalizes preCICE.
void initialize()
Fully initializes preCICE and coupling data.
void writeData(::precice::string_view meshName, ::precice::string_view dataName, ::precice::span< const VertexID > ids, ::precice::span< const double > values)
Writes data to a mesh.
void setMeshVertices(::precice::string_view meshName, ::precice::span< const double > coordinates, ::precice::span< VertexID > ids)
Creates multiple mesh vertices.
double getMaxTimeStepSize() const
Get the maximum allowed time step size of the current window.
void advance(double computedTimeStepSize)
Advances preCICE after the solver has computed one time step.
int getMeshDimensions(::precice::string_view meshName) const
Returns the spatial dimensionality of the given mesh.
void readData(::precice::string_view meshName, ::precice::string_view dataName, ::precice::span< const VertexID > ids, double relativeReadTime, ::precice::span< double > values) const
Reads data values from a mesh. Values correspond to a given point in time relative to the beginning o...
void resetMesh(::precice::string_view meshName)
Removes all vertices and connectivity information from the mesh.
contains the testing framework.
Definition helper.hpp:9
T resize(T... args)
T size(T... args)
QuickTest & expect(const std::vector< double > &expected)
QuickTest & writeCheckpoint()
Definition QuickTest.hpp:67
std::vector< VertexID > vertexIDs
QuickTest & advance(double dt)
Definition QuickTest.hpp:84
QuickTest & writeAll(double d)
Definition QuickTest.hpp:96
std::vector< double > read()
QuickTest(Participant &p, Mesh m, WriteData w)
Definition QuickTest.hpp:30
QuickTest & setVertices(const std::vector< double > &pos)
Definition QuickTest.hpp:40
QuickTest & expectAll(double e)
QuickTest(Participant &p, Mesh m, ReadData r, WriteData w)
Definition QuickTest.hpp:35
QuickTest(Participant &p, Mesh m, ReadData r)
Definition QuickTest.hpp:25
QuickTest & expectWriteCheckpoint()
QuickTest & expectReadCheckpoint()
QuickTest & write(const std::vector< double > &data)
Definition QuickTest.hpp:90
QuickTest & expectCouplingCompleted()