8 #define BOOST_TEST_DYN_LINK
9 #define BOOST_TEST_MODULE "Test module for cf3::math::LSS where testing LSS::System and the dummy EmptyLSS."
13 #include <boost/test/unit_test.hpp>
14 #include <boost/assign/std/vector.hpp>
36 m_argc = boost::unit_test::framework::master_test_suite().argc;
37 m_argv = boost::unit_test::framework::master_test_suite().argv;
48 cp = common::allocate_component<common::PE::CommPattern>(
"commpattern");
49 gid += 0,1,2,3,4,5,6,7,8,9;
50 rnk += 0,0,0,0,0,0,0,0,0,0;
51 conn += 0,2,1,2,2,7,3,8,4,5,5,2,6,0,7,1,8,7,9,8;
52 startidx += 0,2,4,6,8,10,12,14,16,18,20;
53 cp->insert(
"gid",gid,1,
false);
56 std::vector<Uint>
gid;
59 std::vector<Uint>
rnk;
60 boost::shared_ptr<common::PE::CommPattern>
cp;
65 sys = common::allocate_component<LSS::System>(
"system");
66 std::string solvertype(
"cf3.math.LSS.EmptyLSSMatrix");
67 sys->options().option(
"matrix_builder").change_value(solvertype);
68 BOOST_CHECK_EQUAL(sys->is_created(),
false);
69 sys->create(*cp,4u,conn,startidx);
73 boost::shared_ptr<LSS::System>
sys;
85 #define CHECK_BLOCKACCUMULATOR_IS_CONSTANT(ba,refval) { \
86 BOOST_CHECK_EQUAL(ba.mat.isConstant(refval,1.e-10),true); \
87 Real sum=ba.mat.sum(); \
88 Real numentries=(Real)(ba.mat.rows()*ba.mat.cols()); \
89 BOOST_CHECK_CLOSE(sum,numentries*refval,1.e-10); \
90 BOOST_CHECK_EQUAL(ba.rhs.isConstant(refval,1.e-10),true); \
92 numentries=(Real)(ba.rhs.rows()*ba.rhs.cols()); \
93 BOOST_CHECK_CLOSE(sum,numentries*refval,1.e-10); \
94 BOOST_CHECK_EQUAL(ba.sol.isConstant(refval,1.e-10),true); \
96 numentries=(Real)(ba.sol.rows()*ba.sol.cols()); \
97 BOOST_CHECK_CLOSE(sum,numentries*refval,1.e-10); \
110 CFinfo.setFilterRankZero(
false);
120 BOOST_CHECK_EQUAL(sys->matrix()->is_created(),
true);
121 BOOST_CHECK_EQUAL(sys->rhs()->is_created(),
true);
122 BOOST_CHECK_EQUAL(sys->solution()->is_created(),
true);
123 BOOST_CHECK_EQUAL(sys->is_created(),
true);
125 BOOST_CHECK_EQUAL(sys->is_created(),
false);
134 BOOST_CHECK_EQUAL(sys->matrix()->blockrow_size(),10);
135 BOOST_CHECK_EQUAL(sys->matrix()->blockcol_size(),10);
136 BOOST_CHECK_EQUAL(sys->matrix()->neq(),4);
137 BOOST_CHECK_EQUAL(sys->solution()->blockrow_size(),10);
138 BOOST_CHECK_EQUAL(sys->solution()->neq(),4);
139 BOOST_CHECK_EQUAL(sys->rhs()->blockrow_size(),10);
140 BOOST_CHECK_EQUAL(sys->rhs()->neq(),4);
141 BOOST_CHECK_EQUAL(sys->matrix()->solvertype(),
"EmptyLSS");
142 BOOST_CHECK_EQUAL(sys->solution()->solvertype(),
"EmptyLSS");
143 BOOST_CHECK_EQUAL(sys->rhs()->solvertype(),
"EmptyLSS");
144 BOOST_CHECK_EQUAL(sys->solvertype(),
"EmptyLSS");
156 BOOST_CHECK_EQUAL(ba.mat.rows(),8);
157 BOOST_CHECK_EQUAL(ba.mat.cols(),8);
158 BOOST_CHECK_EQUAL(ba.rhs.rows(),8);
159 BOOST_CHECK_EQUAL(ba.rhs.cols(),1);
160 BOOST_CHECK_EQUAL(ba.sol.rows(),8);
161 BOOST_CHECK_EQUAL(ba.sol.cols(),1);
168 BOOST_CHECK_EQUAL(ba.mat.rows(),10);
169 BOOST_CHECK_EQUAL(ba.mat.cols(),10);
170 BOOST_CHECK_EQUAL(ba.rhs.rows(),10);
171 BOOST_CHECK_EQUAL(ba.rhs.cols(),1);
172 BOOST_CHECK_EQUAL(ba.sol.rows(),10);
173 BOOST_CHECK_EQUAL(ba.sol.cols(),1);
184 BOOST_TEST_CHECKPOINT(
"get_values" );
189 BOOST_TEST_CHECKPOINT(
"set_values" );
192 BOOST_TEST_CHECKPOINT(
"add_values" );
195 BOOST_TEST_CHECKPOINT(
"dirichlet" );
196 sys->dirichlet(0,0,0.,
true);
198 BOOST_TEST_CHECKPOINT(
"periodicity" );
199 sys->periodicity (0,0);
201 BOOST_TEST_CHECKPOINT(
"get_diagonal" );
202 sys->get_diagonal(diag);
203 BOOST_CHECK_EQUAL(diag.size(),sys->matrix()->blockrow_size()*sys->matrix()->neq());
205 BOOST_FOREACH(Real i, diag) testval+=i;
206 BOOST_CHECK_CLOSE(testval,0., 1.
e-10);
208 BOOST_TEST_CHECKPOINT(
"set_diagonal" );
209 sys->set_diagonal(diag);
211 BOOST_TEST_CHECKPOINT(
"add_diagonal" );
212 sys->add_diagonal(diag);
214 BOOST_TEST_CHECKPOINT(
"reset" );
217 BOOST_TEST_CHECKPOINT(
"print" );
220 BOOST_TEST_CHECKPOINT(
"matrix::get_value" );
222 sys->matrix()->get_value(0,0,testval);
223 BOOST_CHECK_EQUAL(testval,0.);
225 BOOST_TEST_CHECKPOINT(
"matrix::set_value" );
226 sys->matrix()->set_value(0,0,testval);
228 BOOST_TEST_CHECKPOINT(
"matrix::add_value" );
229 sys->matrix()->add_value(0,0,testval);
231 BOOST_TEST_CHECKPOINT(
"rhs::get_value" );
233 sys->rhs()->get_value(0,testval);
234 BOOST_CHECK_EQUAL(testval,0.);
236 BOOST_TEST_CHECKPOINT(
"rhs::set_value" );
237 sys->rhs()->set_value(0,testval);
239 BOOST_TEST_CHECKPOINT(
"rhs::add_value" );
240 sys->rhs()->add_value(0,testval);
250 boost::shared_ptr<LSS::System> sys2 = common::allocate_component<LSS::System>(
"system2");
251 std::string solvertype(
"cf3.math.LSS.EmptyLSSMatrix");
252 sys2->options().option(
"matrix_builder").change_value(solvertype);
253 sys2->create(*cp,4u,conn,startidx);
254 sys2->matrix()->rename(
"Matrix2");
255 sys2->rhs()->rename(
"RHS2");
256 sys2->solution()->rename(
"Solution2");
258 boost::shared_ptr<Matrix> sw_mat = boost::dynamic_pointer_cast<
Matrix>(sys2->remove_component(
"Matrix2"));
259 boost::shared_ptr<Vector> sw_sol = boost::dynamic_pointer_cast<
Vector>(sys2->remove_component(
"Solution2"));
260 boost::shared_ptr<Vector> sw_rhs = boost::dynamic_pointer_cast<
Vector>(sys2->remove_component(
"RHS2"));
262 sys->swap(sw_mat, sw_sol, sw_rhs);
263 BOOST_CHECK_EQUAL(sys->matrix()->name(),
"Matrix2");
264 BOOST_CHECK_EQUAL(sys->solution()->name(),
"Solution2");
265 BOOST_CHECK_EQUAL(sys->rhs()->name(),
"RHS2");
272 CFinfo.setFilterRankZero(
true);
279 BOOST_AUTO_TEST_SUITE_END()
#define CFinfo
these are always defined
void build_input_data()
create a dummy commpattern
Safe pointer to an object. This is the supported method for referring to components.
#define CHECK_BLOCKACCUMULATOR_IS_CONSTANT(ba, refval)
This header collects all the headers needed for the linear system solver, also including configure-ti...
Basic Classes for Mathematical applications used by COOLFluiD.
Parallel Communication Pattern. This class provides functionality to collect communication. For efficiency it works such a way that you submit your request via the constructor or the add/remove/move magic triangle and then call setup to modify the commpattern. The data needed to be kept synchronous can be registered via the insert function. The word node here means any kind of "point of storage", in this context it is not directly related with the computational mesh.
std::vector< Uint > startidx
boost::shared_ptr< common::PE::CommPattern > cp
Real e()
Definition of the Unit charge [C].
~LSSSystem_EmptyLSSFixture()
common tear-down for each test case
boost::shared_ptr< LSS::System > sys
void build_system()
build a system
LSSSystem_EmptyLSSFixture()
common setup for each test case
void init(int argc=0, char **args=0)
Top-level namespace for coolfluid.
BOOST_AUTO_TEST_CASE(init_mpi)
static Comm & instance()
Return a reference to the current PE.