7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for cf3::mesh::Dictionary"
11 #include <boost/test/unit_test.hpp>
12 #include <boost/assign/list_of.hpp>
13 #include <boost/foreach.hpp>
33 using namespace boost;
62 template <
typename Derived>
69 template <
typename Derived>
86 mesh_gen.
options().
set(
"lengths",std::vector<Real>(2,5.));
87 mesh_gen.
options().
set(
"nb_cells",std::vector<Uint>(2,5u));
102 Entities& elements = *elements_handle;
117 BOOST_CHECK_EQUAL( elem_fields.size() , 45);
118 BOOST_CHECK_EQUAL( elem_fields.entities_range().size() , 5u);
124 const Entities& elements = *elements_handle;
125 const Space& space = elem_fields.space(elements);
131 BOOST_CHECK_EQUAL( point, cell_idx );
140 Field& solution = elem_fields.create_field(
"solution",
"rho[s],V[v],p[s]");
141 Field&
volume = elem_fields.create_field(
"volume");
143 BOOST_CHECK_EQUAL(solution.
size() , elem_fields.size());
144 BOOST_CHECK_EQUAL(solution.
row_size() , 4);
145 BOOST_CHECK_EQUAL(solution.
array().num_elements() , solution.
size()*solution.
row_size());
146 BOOST_CHECK_EQUAL(solution.
dict().
uri().
string() , elem_fields.uri().string() );
147 BOOST_CHECK_EQUAL(volume.
size() , elem_fields.size());
148 BOOST_CHECK_EQUAL(volume.
dict().
uri().
string() , elem_fields.uri().string() );
151 BOOST_CHECK_EQUAL(find_components<Field>(elem_fields).size() , 3u);
153 BOOST_CHECK_EQUAL( field.
dict().
uri().
string() , elem_fields.uri().string());
155 BOOST_CHECK_EQUAL(elem_fields.field(
"volume").uri().string() , volume.
uri().
string());
170 BOOST_CHECK_EQUAL ( point_P2_fields.size() , 121u );
184 Entities& elements = *elements_handle;
185 const Space& space = volume.space(elements);
198 Field& point_field = points_P2->create_field(
"point_field");
203 Entities& elements = *elements_handle;
204 const Space& space = point_field.space(elements);
208 point_field[point][0] = 1.;
218 Field& solution = elems_P0->create_field(
"solution",
"sol[1]");
219 Field& solution_copy = elems_P0->create_field(
"solution_copy",solution.descriptor().description());
222 solution[0][0] = 25.;
223 solution_copy = solution;
224 BOOST_CHECK_EQUAL ( solution_copy[0][0] , 25. );
225 solution_copy += solution_copy;
226 BOOST_CHECK_EQUAL ( solution_copy[0][0] , 50. );
228 BOOST_CHECK_EQUAL ( solution_copy[0][0] , 100. );
230 BOOST_CHECK_EQUAL ( solution_copy[0][0] , 50. );
231 solution_copy *= solution_copy;
232 BOOST_CHECK_EQUAL ( solution_copy[0][0] , 2500. );
233 solution_copy /= solution_copy;
234 BOOST_CHECK_EQUAL ( solution_copy[0][0] , 1. );
235 solution_copy -= solution_copy;
236 BOOST_CHECK_EQUAL ( solution_copy[0][0] , 0. );
244 Field& solution = elems_P0->create_field(
"solution",4);
256 p.setConstant(101000);
259 T.setConstant(298.15);
271 rhoE = p/(gamma-1) + 0.5 * rho * (u.pow(2) + v.pow(2));
273 std::cout << U << std::endl;
274 std::cout << solution << std::endl;
276 BOOST_CHECK_EQUAL( U.rows() , solution.size() );
277 BOOST_CHECK_EQUAL( U.cols() , 2u );
278 BOOST_CHECK_EQUAL( p.rows() , solution.size() );
279 BOOST_CHECK_EQUAL( p.cols() , 1u );
281 for (
int i=0; i<solution.size(); ++i)
283 BOOST_CHECK_EQUAL( solution[i][0] , 101000./(R*298.15) );
284 BOOST_CHECK_EQUAL( solution[i][1] , 30. * solution[i][0] );
285 BOOST_CHECK_EQUAL( solution[i][2] , 0. );
286 BOOST_CHECK_EQUAL( solution[i][3] , 101000./(gamma-1.) + 0.5*solution[i][0]*30*30 );
289 for (
int i=0; i<solution.size(); ++i)
291 solution[i][0] = pressure.
scalar(i)/(R*temperature.
scalar(i));
292 solution[i][1] = velocity[i][
XX] * solution[i][0];
293 solution[i][2] = velocity[i][
YY] * solution[i][0];
294 solution[i][3] = pressure.
scalar(i)/(gamma-1.) + 0.5 * solution[i][0] * velocity.
vector(i).squaredNorm();
297 for (
int i=0; i<solution.size(); ++i)
299 BOOST_CHECK_EQUAL( solution[i][0] , 101000./(R*298.15) );
300 BOOST_CHECK_EQUAL( solution[i][1] , 30. * solution[i][0] );
301 BOOST_CHECK_EQUAL( solution[i][2] , 0. );
302 BOOST_CHECK_EQUAL( solution[i][3] , 101000./(gamma-1.) + 0.5*solution[i][0]*30*30 );
312 BOOST_AUTO_TEST_SUITE_END()
Real & scalar(const Uint r)
std::string name(ComponentWrapper &self)
virtual void execute()
execute
const std::vector< Handle< Entities > > & entities_range() const
Dictionary & create_discontinuous_space(const std::string &space_name, const std::string &space_lib_name, const std::vector< Handle< Entities > > &entities)
external boost library namespace
Real R()
Definition of the ideal gas constant [J/mol K].
Space & geometry_space() const
Dictionary & create_continuous_space(const std::string &space_name, const std::string &space_lib_name, const std::vector< Handle< Entities > > &entities)
RowVectorRef vector(const Uint r)
boost::proto::terminal< SFOp< VolumeOp > >::type const volume
Static terminals that can be used in proto expressions.
void prefix_variable_names(const std::string &prefix)
ElementType & element_type() const
return the elementType
URI uri() const
Construct the full path.
Eigen::Map< ArrayStorage, Eigen::Unaligned, Eigen::Stride< Eigen::Dynamic, Eigen::Dynamic > > Ref
static Handle< Mesh > m_mesh
common mesh accessed by all tests
bool check_sanity(std::vector< std::string > &messages) const
Check if all fields are compatible.
#define boost_foreach
lowercase version of BOOST_FOREACH
Real e()
Definition of the Unit charge [C].
Dictionary & dict() const
Handle< Component const > root() const
Generate a simple carthesian P1 mesh without grading.
DictionaryTests_Fixture()
common setup for each test case
Uint size() const
return the number of elements
~DictionaryTests_Fixture()
common tear-down for each test case
Basic Classes for Mesh applications used by COOLFluiD.
virtual Real volume(const RealMatrix &nodes) const =0
Top-level namespace for coolfluid.
Real gamma()
Definition of the Euler gamma.
Uint offset(const std::string &name) const
RealMatrix get_coordinates(const Uint elem_idx) const
Lookup element coordinates.
const Space & space(const Entities &entities) const
Return the space of given entities.
Uint row_size(Uint i=0) const
BOOST_AUTO_TEST_CASE(test_MeshCreation)
Eigen::Block< Ref, Eigen::Dynamic, 1 > RefCol
unsigned int Uint
typedef for unsigned int
Uint var_length(const std::string &name) const
math::VariablesDescriptor & descriptor() const
Dictionary & geometry_fields() const
void set(const std::string &pname, const boost::any &val)
void map(Field &field, Eigen::Map< Derived > &v, const Uint row_idx, const Uint var_idx)
Uint size() const
Number of rows of contained fields.
Most basic kernel library.
std::string string() const
Connectivity & connectivity()
connectivity table to dictionary entries
std::string demangle(const char *type)
Function to demangle the return of typeid()