CppNoddy  0.92
All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Modules Pages
Functions
2DNodeMesh.cpp File Reference

A simple check of the TwoD_Node_Mesh container that stores nodal data over a given mesh. More...

#include <Generic_bundle.h>
#include <TwoD_Node_Mesh.h>

Go to the source code of this file.

Functions

int main ()
 

Detailed Description

A simple check of the TwoD_Node_Mesh container that stores nodal data over a given mesh.

This simply does a remeshing check.

Definition in file 2DNodeMesh.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 14 of file 2DNodeMesh.cpp.

15{
16 cout.precision( 10 );
17 cout << "\n";
18 cout << "=== TwoD_Node_Mesh: very basic read/write test ======\n";
19 cout << "\n";
20
21 std::size_t nx( 11 );
22 std::size_t ny( 21 );
25 std::size_t nx2( 31 );
26 std::size_t ny2( 41 );
29
30
31 TwoD_Node_Mesh<double> mesh( x, y, 1 );
32 // write
33 for ( std::size_t i = 0; i < nx; ++i )
34 {
35 for ( std::size_t j = 0; j < ny; ++j )
36 {
37 mesh( i, j, 0 ) = cos( M_PI * x[ i ] ) * sin( M_PI * y[ j ] );
38 }
39 }
40
41 //mesh.dump_gnu( "./DATA/mesh1.dat" );
42 mesh.remesh1( x2, y2 );
43 //mesh.dump_gnu( "./DATA/mesh2.dat" );
44 mesh.remesh1( x, y );
45 //mesh.dump_gnu( "./DATA/mesh3.dat" );
46
47 // read
48 for ( std::size_t j = 0; j < ny; ++j )
49 {
50 for ( std::size_t i = 0; i < nx; ++i )
51 {
52 mesh( i, j, 0 ) -= cos( M_PI * x[ i ] ) * sin( M_PI * y[ j ] );
53 }
54 }
55
56 // check diff
57 const double diff = mesh.get_var_as_matrix( 0 ).inf_norm();
58 if ( diff > 1.e-14 )
59 {
60 cout << "\033[1;31;48m * FAILED \033[0m\n";
61 cout.precision( 10 );
62 cout << "Difference following remeshing is " << diff << "\n";
63 return 1;
64 }
65 else
66 {
67 cout << "\033[1;32;48m * PASSED \033[0m\n";
68 return 0;
69 }
70
71}
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
A two dimensional mesh utility object.
DenseVector< double > uniform_node_vector(const double &lower, const double &upper, const std::size_t &N)
Return a DENSE vector with the nodal points of a uniform mesh distributed between the upper/lower bou...
Definition: Utility.cpp:113

References CppNoddy::TwoD_Node_Mesh< _Type >::get_var_as_matrix(), CppNoddy::TwoD_Node_Mesh< _Type >::remesh1(), and CppNoddy::Utility::uniform_node_vector().

© 2012

R.E. Hewitt