7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Tests mesh construction"
11 #include <boost/test/unit_test.hpp>
12 #include <boost/foreach.hpp>
34 using namespace boost;
40 public boost::iterator_facade<ElementIterator,
42 boost::random_access_traversal_tag,
48 boost::random_access_traversal_tag,
59 const Uint element_idx=0)
60 : element(entities,element_idx) {}
63 friend class boost::iterator_core_access;
65 bool equal(ElementIterator
const& other)
const {
return (element == other.
element); }
77 void advance(
const difference_type
n) { element.idx +=
n; }
79 template <
typename T2>
80 difference_type
distance_to(ElementIterator
const& other)
const
98 return boost::make_iterator_range(begin,begin+static_cast<ElementIterator::difference_type>(entities.
size()));
165 Uint quad[] = {A,B,C,D};
166 std::vector<Uint> quadVec;
167 quadVec.assign(quad,quad+4);
173 Uint triag[] = {A,B,C};
174 std::vector<Uint> triagVec;
175 triagVec.assign(triag,triag+3);
182 Uint quad[] = {A,B,C,
D,E,
F,G,H,I};
183 std::vector<Uint> quadVec;
184 quadVec.assign(quad,quad+9);
192 Uint triag[] = {A,B,C,
D,E,F};
193 std::vector<Uint> triagVec;
194 triagVec.assign(triag,triag+6);
210 AssertionManager::instance().AssertionThrows =
true;
225 Elements& quadRegion = superRegion.create_elements(
"cf3.mesh.LagrangeP1.Quad2D",nodes);
226 Elements& triagRegion = superRegion.create_elements(
"cf3.mesh.LagrangeP1.Triag2D",nodes);
247 coordinatesBuffer.add_row(create_coord( 0.0 , 0.0 ));
248 coordinatesBuffer.add_row(create_coord( 1.0 , 0.0 ));
249 coordinatesBuffer.add_row(create_coord( 1.0 , 1.0 ));
250 coordinatesBuffer.add_row(create_coord( 0.0 , 1.0 ));
251 coordinatesBuffer.add_row(create_coord( 1.0 , 2.0 ));
252 coordinatesBuffer.add_row(create_coord( 0.0 , 2.0 ));
253 coordinatesBuffer.add_row(create_coord( 2.0 , 2.0 ));
254 coordinatesBuffer.add_row(create_coord( 2.0 , 1.0 ));
255 coordinatesBuffer.add_row(create_coord( 2.0 , 0.0 ));
258 qTableBuffer.add_row(create_quad( 0 , 1 , 2 , 3 ));
259 qTableBuffer.add_row(create_quad( 3 , 2 , 4 , 5 ));
261 tTableBuffer.add_row(create_triag( 1 , 8 , 2 ));
262 tTableBuffer.add_row(create_triag( 8 , 7 , 2 ));
263 tTableBuffer.add_row(create_triag( 2 , 7 , 4 ));
264 tTableBuffer.add_row(create_triag( 7 , 6 , 4 ));
268 coordinatesBuffer.flush();
269 qTableBuffer.flush();
270 tTableBuffer.flush();
273 quadRegion.resize(quadRegion.size());
285 BOOST_CHECK_EQUAL(coordRef[0],1.0);
286 BOOST_CHECK_EQUAL(coordRef[1],1.0);
289 BOOST_FOREACH(
Elements& region, find_components_recursively<Elements>(superRegion))
293 std::vector<Real>
volumes(nbRows);
299 for (
Uint iElem=0; iElem<nbRows; ++iElem)
301 fill(elementCoordinates, region_coordinates, region_connTable[iElem]);
303 volumes[iElem]=elementType.
volume(elementCoordinates);
306 if(elementType.
shape() == GeoShape::QUAD)
307 BOOST_CHECK_EQUAL(volumes[iElem],1.0);
308 if(elementType.
shape() == GeoShape::TRIAG)
309 BOOST_CHECK_EQUAL(volumes[iElem],0.5);
322 boost::shared_ptr< MeshWriter > meshwriter = build_component_abstract_type<MeshWriter>(
"cf3.mesh.gmsh.Writer",
"meshwriter");
323 meshwriter->write_from_to(mesh,
"p1-mesh.msh");
326 Entity entity(quadRegion,0);
330 BOOST_CHECK_EQUAL( space_elem.field_indices()[0] , 0 );
333 RealMatrix space_coords = space_elem.get_coordinates();
335 BOOST_CHECK( geom_coords == space_coords );
338 for(
SpaceElement elem(quadRegion.space(nodes)); elem.idx<quadRegion.size(); ++elem.idx)
342 CFinfo << field_idx <<
" ";
348 std::cout << entity << std::endl;
357 AssertionManager::instance().AssertionThrows =
true;
362 boost::shared_ptr<Component>
root = boost::static_pointer_cast<
Component>(allocate_component<Group>(
"root"));
371 Elements& quadRegion = superRegion.create_elements(
"cf3.mesh.LagrangeP2.Quad2D",nodes);
372 Elements& triagRegion = superRegion.create_elements(
"cf3.mesh.LagrangeP2.Triag2D",nodes);
402 coordinatesBuffer.add_row(create_coord( 0.0 , 0.0 ));
403 coordinatesBuffer.add_row(create_coord( 1.0 , 0.0 ));
404 coordinatesBuffer.add_row(create_coord( 1.0 , 1.0 ));
405 coordinatesBuffer.add_row(create_coord( 0.0 , 1.0 ));
406 coordinatesBuffer.add_row(create_coord( 1.0 , 2.0 ));
407 coordinatesBuffer.add_row(create_coord( 0.0 , 2.0 ));
408 coordinatesBuffer.add_row(create_coord( 2.0 , 2.0 ));
409 coordinatesBuffer.add_row(create_coord( 2.0 , 1.0 ));
410 coordinatesBuffer.add_row(create_coord( 2.0 , 0.0 ));
413 coordinatesBuffer.add_row(create_coord( 0.5 , 0.0 ));
414 coordinatesBuffer.add_row(create_coord( 1.0 , 0.5 ));
415 coordinatesBuffer.add_row(create_coord( 0.5 , 1.0 ));
416 coordinatesBuffer.add_row(create_coord( 0.0 , 0.5 ));
417 coordinatesBuffer.add_row(create_coord( 0.5 , 0.5 ));
418 coordinatesBuffer.add_row(create_coord( 1.0 , 1.5 ));
419 coordinatesBuffer.add_row(create_coord( 0.5 , 2.0 ));
420 coordinatesBuffer.add_row(create_coord( 0.0 , 1.5 ));
421 coordinatesBuffer.add_row(create_coord( 0.5 , 1.5 ));
422 coordinatesBuffer.add_row(create_coord( 1.5 , 0.0 ));
423 coordinatesBuffer.add_row(create_coord( 1.5 , 0.5 ));
424 coordinatesBuffer.add_row(create_coord( 2.0 , 0.5 ));
425 coordinatesBuffer.add_row(create_coord( 1.5 , 1.0 ));
426 coordinatesBuffer.add_row(create_coord( 1.5 , 1.5 ));
427 coordinatesBuffer.add_row(create_coord( 2.0 , 1.5 ));
428 coordinatesBuffer.add_row(create_coord( 1.5 , 2.0 ));
434 qTableBuffer.add_row(create_quad_p2( 0 , 1 , 2 , 3 , 9 , 10, 11, 12, 13 ));
435 qTableBuffer.add_row(create_quad_p2( 3 , 2 , 4 , 5 , 11, 14, 15, 16, 17 ));
437 tTableBuffer.add_row(create_triag_p2( 1 , 8 , 2 , 18 , 19 , 10 ));
438 tTableBuffer.add_row(create_triag_p2( 8 , 7 , 2 , 20 , 21 , 19 ));
439 tTableBuffer.add_row(create_triag_p2( 2 , 7 , 4 , 21 , 22 , 14 ));
440 tTableBuffer.add_row(create_triag_p2( 7 , 6 , 4 , 23 , 24 , 22 ));
444 coordinatesBuffer.flush();
445 qTableBuffer.flush();
446 tTableBuffer.flush();
449 quadRegion.resize(quadRegion.size());
461 BOOST_CHECK_EQUAL(coordRef[0],1.0);
462 BOOST_CHECK_EQUAL(coordRef[1],1.0);
498 boost::shared_ptr< MeshWriter > meshwriter = build_component_abstract_type<MeshWriter>(
"cf3.mesh.gmsh.Writer",
"meshwriter");
499 meshwriter->write_from_to(mesh,
"p2-mesh.msh");
505 BOOST_AUTO_TEST_SUITE_END()
#define CFinfo
these are always defined
const ShapeFunction & shape_function() const
RealMatrix get_coordinates() const
external boost library namespace
Space & geometry_space() const
void initialize_nodes(const Uint nb_nodes, const Uint dimension)
will among others set the coordinate dimension for the nodes
difference_type distance_to(ElementIterator const &other) const
Connectivity::ConstRow field_indices() const
std::vector< Uint > create_triag_p2(const Uint A, const Uint B, const Uint C, const Uint D, const Uint E, const Uint F)
create a Uint vector with 3 node ID's
ElementType & element_type() const
return the elementType
Region & create_region(const std::string &name)
Buffer create_buffer(const size_t buffersize=16384)
bool is_ghost(const Uint idx) const
#define boost_foreach
lowercase version of BOOST_FOREACH
const Field & coordinates() const
common::List< Uint > & rank()
void advance(const difference_type n)
Entities & support() const
Access the geometric support.
boost::proto::terminal< SFOp< NodesOp > >::type const nodes
~MeshConstruction_Fixture()
common tear-down for each test case
Dictionary & geometry_fields() const
Const access to the coordinates.
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > RealMatrix
Dynamic sized matrix of Real scalars.
SpaceElement(Space &component, const Uint index=0)
ElementIterator(Entities &entities, const Uint element_idx=0)
Uint size() const
return the number of elements
RealMatrix get_coordinates() const
const ShapeFunction & element_type() const
return the elementType
common::List< Uint > & glb_idx()
Mutable access to the list of nodes.
Dictionary & dict() const
Const access to the coordinates.
Basic Classes for Mesh applications used by COOLFluiD.
virtual Real volume(const RealMatrix &nodes) const =0
const Entity & dereference() const
dereferencing
Eigen::Matrix< Real, Eigen::Dynamic, 1 > RealVector
Dynamic sized column vector.
BaseT::difference_type difference_type
GeoShape::Type shape() const
bool equal(ElementIterator const &other) const
boost::iterator_facade< ElementIterator, Entity, boost::random_access_traversal_tag, Entity > BaseT
void allocate_coordinates(RealMatrix &coordinates) const
Allocate element coordinates.
Top-level namespace for coolfluid.
std::vector< Uint > create_quad(const Uint &A, const Uint &B, const Uint &C, const Uint &D)
create a Uint vector with 4 node ID's
void resize(const Uint nb_elem)
BOOST_AUTO_TEST_CASE(P1_2D_MeshConstruction)
void fill(NodeValuesT &to_fill, const common::Table< Real > &data_array, const RowT &element_row, const Uint start=0)
Fill STL-vector like per-node data storage.
Component holding a 2 dimensional array of a templated type.
RealMatrix get_coordinates(const Uint elem_idx) const
Lookup element coordinates.
RealVector create_coord(const Real &x, const Real &y)
possibly common functions used on the tests below
Uint row_size(Uint i=0) const
boost::proto::terminal< SFOp< CoordinatesOp > >::type const coordinates
boost::iterator_range< ElementIterator > make_range(Entities &entities)
Low storage struct to uniquely identify one element.
unsigned int Uint
typedef for unsigned int
MeshConstruction_Fixture()
common setup for each test case
void allocate_coordinates(RealMatrix &coordinates) const
void resize(const Uint size)
Resize the contained fields.
Region & topology() const
std::vector< Uint > create_triag(const Uint &A, const Uint &B, const Uint &C)
create a Uint vector with 3 node ID's
Dictionary & dict() const
Dictionary this space belongs to.
Dictionary & geometry_fields() const
Base class for defining CF components.
Handle< Component > create_component(const std::string &name, const std::string &builder)
Build a (sub)component of this component using the extended type_name of the component.
Most basic kernel library.
std::vector< Uint > create_quad_p2(const Uint A, const Uint B, const Uint C, const Uint D, const Uint E, const Uint F, const Uint G, const Uint H, const Uint I)
void put_coordinates(RealMatrix &coordinates, const Uint elem_idx) const
Lookup element coordinates.
Connectivity & connectivity()
connectivity table to dictionary entries
void put_coordinates(RealMatrix &coordinates) const