CppNoddy  0.92
Loading...
Searching...
No Matches
1DNodeMeshComplex.cpp
Go to the documentation of this file.
1/// \file 1DNodeMeshComplex.cpp
2/// \ingroup Tests
3/// \ingroup Generic
4/// A simple check of the OneD_Node_Mesh container that
5/// stores nodal data over a given mesh. This checks that
6/// mesh data is interpolated and integrated correctly. We
7/// write \f$ \cos(x) \f$ to a uniform mesh, then check the
8/// integration routines converge appropriately. We then
9/// re-interpolate the data onto a non-uniform mesh and
10/// check the integral again.
11
12#include <OneD_Node_Mesh.h>
13#include <Utility.h>
14
15using namespace CppNoddy;
16using namespace std;
17
18int main()
19{
20 cout.precision( 10 );
21 cout << "\n";
22 cout << "=== OneD_Node_Mesh: complex data on a complex path =\n";
23 cout << "\n";
24
25
26 // Number of points
27 std::size_t N(11);
28 // parameterisation of a complex path
29 DenseVector<double> paramCoords( Utility::uniform_node_vector( 0.0, 1.0, N ) );
30 DenseVector<D_complex> z( N, D_complex(0.0,0.0) );
31 // the data stored on the complex path
33 // i
34 D_complex eye(0.0,1.0);
35
36 // Set the variable values to be defined by a Cosine.
37 for ( std::size_t i = 0; i < N; ++i ) {
38 double s = paramCoords[i];
39 Q.coord(i) = s + eye*s*(1-s);
40 // mesh stores
41 Q( i, 0 ) = sin( Q.coord(i) );
42 }
43 Q.dump_gnu("./data.dat");
44 Q.dump();
45
46 OneD_Node_Mesh<D_complex,D_complex> P( "./data.dat", N, 1 );
47 P.dump();
48
49}
int main()
A specification for a one dimensional mesh object.
A spec for a collection of utility functions.
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
A one dimensional mesh utility object.
void dump() const
A simple method for dumping data to std::cout.
const _Xtype & coord(const std::size_t &node) const
Access a nodal position.
void dump_gnu(std::string filename, int precision=10) const
A simple method for dumping data to a file for gnuplot.
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...
std::complex< double > D_complex
A complex double precision number using std::complex.
Definition: Types.h:98

© 2012

R.E. Hewitt