CppNoddy  0.92
Loading...
Searching...
No Matches
2DNodeMesh.cpp
Go to the documentation of this file.
1/// \file 2DNodeMesh.cpp
2/// \ingroup Tests
3/// \ingroup Generic
4/// A simple check of the TwoD_Node_Mesh container that
5/// stores nodal data over a given mesh. This simply
6/// does a remeshing check.
7
8#include <Generic_bundle.h>
9#include <TwoD_Node_Mesh.h>
10
11using namespace CppNoddy;
12using namespace std;
13
14int main()
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}
int main()
Definition: 2DNodeMesh.cpp:14
A shorter bundled include file for ODE_BVP and PDE_IBVP codes.
A specification for a two dimensional mesh object.
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
A two dimensional mesh utility object.
DenseMatrix< _Type > get_var_as_matrix(std::size_t var) const
Return a matrix corresponding to each nodal point in the mesh Each matrix element will contain a spec...
void remesh1(const DenseVector< double > &newX, const DenseVector< double > &newY)
Interpolate this mesh data (bilinearly) into a new mesh with nodal points defined in the argument lis...
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
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...

© 2012

R.E. Hewitt