CppNoddy  0.92
Loading...
Searching...
No Matches
OneD_Node_Mesh.cpp
Go to the documentation of this file.
1/// \file OneD_Node_Mesh.cpp
2/// Implementation of the one dimensional (non-)uniformly distributed mesh object.
3
4#include <complex>
5#include <vector>
6#include <string>
7
8#include <DenseVector.h>
9#include <OneD_Node_Mesh.h>
10#include <Exceptions.h>
11#include <Types.h>
12
13namespace CppNoddy {
14
15
16 template < typename _Type, typename _Xtype >
18#ifdef PARANOID
19 if(U.size() != m_nv) {
20 std::string problem;
21 problem = " The OneD_Node_Mesh.set_node method is trying to add \n";
22 problem += " an DenseVector of variables of a different size to that \n";
23 problem += " stored at other nodal points. \n";
24 throw ExceptionGeom(problem, m_nv, U.size());
25 }
26#endif
27 for(std::size_t var = 0; var < U.size(); ++var) {
28 m_vars[ node * m_nv + var ] = U[ var ];
29 }
30 }
31
32 template < typename _Type, typename _Xtype >
34#ifdef PARANOID
35 if((node >= m_X.size()) || (node < 0)) {
36 std::string problem;
37 problem = " The OneD_Node_Mesh.get_nodes_vars method is trying to access \n";
38 problem += " a nodal point outside of the range stored. \n";
39 throw ExceptionRange(problem, m_X.size(), node);
40 }
41#endif
42 DenseVector<_Type> nodes_vars;
43 for(std::size_t var = 0; var < m_nv; ++var) {
44 nodes_vars.push_back(m_vars[ node * m_nv + var ]);
45 }
46 return nodes_vars;
47 }
48
49 template < typename _Type, typename _Xtype >
51 return m_X.size();
52 }
53
54 template < typename _Type, typename _Xtype >
56 return m_nv;
57 }
58
59 template < typename _Type, typename _Xtype >
61 return m_X;
62 }
63
64 template <>
65 DenseVector<double> OneD_Node_Mesh<double, double>::find_roots1(const std::size_t &var, double value) const {
67 for(std::size_t node = 0; node < m_X.size() - 1; ++node) {
68 std::size_t offset(node * m_nv + var);
69 // find bracket nodes
70 if((m_vars[ offset ] - value) * (m_vars[ offset + m_nv ] - value) < 0.0) {
71 double deriv = (m_vars[ offset + m_nv ] - m_vars[ offset ]) / (m_X[ node + 1 ] - m_X[ node ]);
72 double x = m_X[ node ] + (value - m_vars[ offset ]) / deriv;
73 // add the left hand node to the roots vector
74 roots.push_back(x);
75 }
76 }
77 return roots;
78 }
79
80 template < typename _Type, typename _Xtype >
82 return m_vars;
83 }
84
85 template < typename _Type, typename _Xtype >
87#ifdef PARANOID
88 if(vec.size() != m_nv * m_X.size()) {
89 std::string problem;
90 problem = "The set_vars_from_vector method has been passed a vector\n";
91 problem += "of a length that is of an incompatible size for this mesh object\n";
92 throw ExceptionRuntime(problem);
93 }
94#endif
95 m_vars = vec;
96 }
97
98 template <>
100#ifdef PARANOID
101 if(std::abs(m_X[ 0 ] - newX[ 0 ]) > 1.e-10 ||
102 std::abs(m_X[ m_X.size() - 1 ] - newX[ newX.size() - 1 ]) > 1.e-10) {
103 std::string problem;
104 problem = " The OneD_Node_Mesh.remesh method has been called with \n";
105 problem += " a passed coordinate vector that has different start and/or \n";
106 problem += " end points from the instantiated object. \n";
107 throw ExceptionRuntime(problem);
108 }
109
110 for(std::size_t i = 0; i < newX.size() - 1; ++i) {
111 if(newX[ i ] >= newX[ i + 1 ]) {
112 std::string problem;
113 problem = " The OneD_Node_Mesh.remesh method has been passed \n";
114 problem += " a non-monotonic coordinate vector. \n";
115 throw ExceptionRuntime(problem);
116 }
117 }
118#endif
119 // copy current state of this mesh
120 DenseVector<double> copy_of_vars(m_vars);
121 // resize the local storage
122 m_vars.resize(newX.size() * m_nv);
123
124 // first nodal values are assumed to be untouched
125 // loop thru destination mesh node at a time
126 for(std::size_t node = 1; node < newX.size() - 1; ++node) {
127 // loop through the source mesh and find the bracket-nodes
128 for(std::size_t i = 0; i < m_X.size(); ++i) {
129 if((m_X[ i ] <= newX[ node ]) && (newX[ node ] < m_X[ i + 1 ])) {
130 // linearly interpolate each variable in the mesh
131 for(std::size_t var = 0; var < m_nv; ++var) {
132 double dX = newX[ node ] - m_X[ i ];
133 double dvarsdX = (copy_of_vars[(i+1)*m_nv + var ] - copy_of_vars[ i*m_nv + var ]) / (m_X[ i + 1 ] - m_X[ i ]);
134 m_vars[ node * m_nv + var ] = copy_of_vars[ i * m_nv + var ] + dX * dvarsdX;
135 }
136 }
137 }
138 }
140 // add the last nodal values to the resized vector
141 for(std::size_t var = 0; var < m_nv; ++var) {
142 m_vars[(newX.size() - 1) * m_nv + var ] = copy_of_vars[(m_X.size() - 1) * m_nv + var ];
143 }
144 // replace the old nodes with the new ones
145 m_X = newX;
146 }
147
148 template <>
149 void OneD_Node_Mesh<std::complex<double>, double>::remesh1(const DenseVector<double>& newX) {
150#ifdef PARANOID
151 if(std::abs(m_X[ 0 ] - newX[ 0 ]) > 1.e-10 ||
152 std::abs(m_X[ m_X.size() - 1 ] - newX[ newX.size() - 1 ]) > 1.e-10) {
153 std::string problem;
154 problem = " The OneD_Node_Mesh.remesh method has been called with \n";
155 problem += " a passed coordinate vector that has different start and/or \n";
156 problem += " end points from the instantiated object. \n";
157 throw ExceptionRuntime(problem);
158 }
159
160 for(std::size_t i = 0; i < newX.size() - 1; ++i) {
161 if(newX[ i ] >= newX[ i + 1 ]) {
162 std::string problem;
163 problem = " The OneD_Node_Mesh.remesh method has been passed \n";
164 problem += " a non-monotonic coordinate vector. \n";
165 throw ExceptionRuntime(problem);
166 }
167 }
168#endif
169 // copy current state of this mesh
170 DenseVector<std::complex<double> > copy_of_vars(m_vars);
171 // resize the local storage
172 m_vars.resize(newX.size() * m_nv);
173
174 // first nodal values are assumed to be untouched
175 // loop thru destination mesh node at a time
176 for(std::size_t node = 1; node < newX.size() - 1; ++node) {
177 // loop through the source mesh and find the bracket-nodes
178 for(std::size_t i = 0; i < m_X.size(); ++i) {
179 if((m_X[ i ] <= newX[ node ]) && (newX[ node ] < m_X[ i + 1 ])) {
180 // linearly interpolate each variable in the mesh
181 for(std::size_t var = 0; var < m_nv; ++var) {
182 double dX = newX[ node ] - m_X[ i ];
183 // if the paranoid checks above are satisfied, then the m_X[ i + 1 ] should still be in bounds
184 std::complex<double> dvarsdX = (copy_of_vars[(i+1)*m_nv + var ] - copy_of_vars[ i*m_nv + var ]) / (m_X[ i + 1 ] - m_X[ i ]);
185 m_vars[ node * m_nv + var ] = copy_of_vars[ i * m_nv + var ] + dX * dvarsdX;
186 }
187 }
188 }
189 }
190
191 // add the last nodal values to the resized vector
192 for(std::size_t var = 0; var < m_nv; ++var) {
193 m_vars[(newX.size() - 1) * m_nv + var ] = copy_of_vars[(m_X.size() - 1) * m_nv + var ];
194 }
195 // replace the old nodes with the new ones
196 m_X = newX;
197
198 }
199
200 template <>
201 void OneD_Node_Mesh<std::complex<double>, std::complex<double> >::remesh1(const DenseVector<std::complex<double> >& z) {
202 std::string problem;
203 problem = " The OneD_Node_Mesh.remesh method has been called with \n";
204 problem += " a complex data set on a complex mesh.\n";
205 throw ExceptionRuntime(problem);
206 }
207
208 template <>
210 for(unsigned node = 0; node < m_X.size() - 1; ++node) {
211 // find bracketing nodes - incl shameless hack for evaluations at the boundary
212 //if ( ( m_X[ node ] < x_pos || std::abs( m_X[ node ] - x_pos ) < 1.e-7 ) &&
213 //( m_X[ node + 1 ] > x_pos || std::abs( m_X[ node + 1 ] - x_pos ) < 1.e-7 ) )
214 if(((m_X[ node ] < x_pos) && (m_X[ node + 1 ] > x_pos))
215 || (std::abs(m_X[ node ] - x_pos) < 1.e-7) || (std::abs(m_X[ node + 1 ] - x_pos) < 1.e-7)) {
216 // distance from left node
217 double delta_x(x_pos - m_X[ node ]);
218 // empty data to return
222 // interpolate data linearly
223 left = get_nodes_vars(node);
224 right = get_nodes_vars(node + 1);
225 deriv = (right - left) / (m_X[ node + 1 ] - m_X[ node ]);
226 // overwrite right
227 right = left + deriv * delta_x;
228 return right;
229 }
230 }
231 std::cout << "You asked for a position of " << x_pos << " in a range " << m_X[ 0 ] << " to " << m_X[ m_X.size() - 1 ] << "\n";
232 std::string problem;
233 problem = "You have asked the OneD_Node_Mesh class to interpolate data at\n";
234 problem += "a point that is outside the range covered by the mesh object.\n";
235 throw ExceptionRuntime(problem);
236 }
237
238
239 template <>
240 DenseVector<std::complex<double> > OneD_Node_Mesh<std::complex<double>, double>::get_interpolated_vars(const double& x_pos) const {
241 for(unsigned node = 0; node < m_X.size() - 1; ++node) {
242 // find bracketing nodes - incl shameless hack for evaluations at the boundary
243 if((m_X[ node ] < x_pos || std::abs(m_X[ node ] - x_pos) < 1.e-7) &&
244 (m_X[ node + 1 ] > x_pos || std::abs(m_X[ node + 1 ] - x_pos) < 1.e-7)) {
245 // distance from left node
246 double delta_x(x_pos - m_X[ node ]);
247 // empty data to return
251 // interpolate data linearly
252 left = get_nodes_vars(node);
253 right = get_nodes_vars(node + 1);
254 deriv = (right - left) / (m_X[ node + 1 ] - m_X[ node ]);
255 // overwrite right
256 right = left + deriv * delta_x;
257 return right;
258 }
259 }
260 std::cout << "You asked for a position of " << x_pos << " in a range " << m_X[ 0 ] << " to " << m_X[ m_X.size() - 1 ] << "\n";
261 std::string problem;
262 problem = "You have asked the OneD_Node_Mesh class to interpolate data at\n";
263 problem += "a point that is outside the range covered by the mesh object.\n";
264 throw ExceptionRuntime(problem);
265 }
266
267
268 template <>
269 DenseVector<std::complex<double> > OneD_Node_Mesh<std::complex<double>, std::complex<double> >::get_interpolated_vars(const std::complex<double>& pos) const {
270 double x_pos(pos.real());
271#ifdef PARANOID
272 std::cout << "WARNING: You are interpolating complex data on a complex mesh with 'get_interpolated_vars'.\n";
273 std::cout << " This does a simple piecewise linear interpolating assuming a single valued path. \n";
274#endif
275 for(unsigned node = 0; node < m_X.size() - 1; ++node) {
276 // find bracketing nodes - incl shameless hack for evaluations at the boundary
277 if((m_X[ node ].real() < x_pos || std::abs(m_X[ node ].real() - x_pos) < 1.e-7) &&
278 (m_X[ node + 1 ].real() > x_pos || std::abs(m_X[ node + 1 ].real() - x_pos) < 1.e-7)) {
279 // distance from left node -- real coordinate is given. We also need to
280 // interpolate between the two complex nodes -- hence imaginary coordinate is implict from
281 // bracketing (complex) nodes
282 std::complex<double> delta_z = (m_X[ node + 1 ] - m_X[ node ]) * (x_pos - m_X[ node ].real()) / (m_X[ node + 1 ].real() - m_X[ node ].real());
283 // empty data to return
287 // interpolate data linearly
288 left = get_nodes_vars(node);
289 right = get_nodes_vars(node + 1);
290 // derivative of the data
291 deriv = (right - left) / (m_X[ node + 1 ] - m_X[ node ]);
292 // overwrite right
293 right = left + deriv * delta_z;
294 return right;
295 }
296 }
297 std::cout << "You asked for a position of " << x_pos << " in a range " << m_X[ 0 ] << " to " << m_X[ m_X.size() - 1 ] << "\n";
298 std::string problem;
299 problem = "You have asked the OneD_Node_Mesh class to interpolate data at\n";
300 problem += "a point that is outside the range covered by the mesh object.\n";
301 problem += "Even for complex nodes we assume the path is single valued.\n";
302 throw ExceptionRuntime(problem);
303 }
304
305 template <>
306 DenseVector<double> OneD_Node_Mesh<std::complex<double>, double >::find_roots1(const std::size_t &var, double value) const {
307 std::string problem;
308 problem = " The OneD_Node_Mesh.find_roots1 method has been called with \n";
309 problem += " a mesh containing complex data.\n";
310 throw ExceptionRuntime(problem);
311 }
312
313 template < typename _Type, typename _Xtype >
314 _Type OneD_Node_Mesh<_Type, _Xtype>::integral2(std::size_t var) const {
315 _Type sum = 0.0;
316 _Xtype dx = 0.0;
317 // sum interior segments
318 for(std::size_t node = 0; node < m_X.size() - 1; ++node) {
319 dx = (m_X[ node + 1 ] - m_X[ node ]);
320 sum += 0.5 * dx * (m_vars[ node * m_nv + var ] + m_vars[(node+1) * m_nv + var ]);
321 }
322 // return the value
323 return sum;
324 }
325
326 template < typename _Type, typename _Xtype >
328 _Xtype sum = 0.0;
329 double dx = 0.0;
330 // sum interior segments
331 for(std::size_t node = 0; node < m_X.size() - 1; ++node) {
332 dx = std::abs(m_X[ node + 1 ] - m_X[ node ]);
333 sum += 0.5 * dx * (std::pow(std::abs(m_vars[ node * m_nv + var ]), 2)
334 + std::pow(std::abs(m_vars[(node + 1) * m_nv + var ]), 2));
335 }
336 // return the value
337 return std::sqrt(sum);
338 }
339
340 template < typename _Type, typename _Xtype >
341 _Type OneD_Node_Mesh<_Type, _Xtype>::integral4(std::size_t var) const {
342 if((m_X.size()) % 2 == 0) {
343 std::string problem;
344 problem = " The OneD_Node_Mesh.Simpson_integral method is trying to run \n";
345 problem += " on a mesh with an even number of points. \n";
346 throw ExceptionRuntime(problem);
347 }
348
349 _Type f0, f1, f2;
350 _Xtype x0, x1, x2;
351
352 _Type sum = 0.0;
353
354 // sum interior segments
355 for(std::size_t node = 0; node < m_X.size() - 2; node += 2) {
356 x0 = m_X[ node ];
357 x1 = m_X[ node + 1 ];
358 x2 = m_X[ node + 2 ];
359 f0 = m_vars[ node * m_nv + var ];
360 f1 = m_vars[(node+1) * m_nv + var ];
361 f2 = m_vars[(node+2) * m_nv + var ];
362 sum += (x2 - x0)
363 * (
364 f1 * pow(x0 - x2, 2) + f0 * (x1 - x2) * (2. * x0 - 3. * x1 + x2)
365 - f2 * (x0 - x1) * (x0 - 3. * x1 + 2. * x2)
366 )
367 / (6. * (x0 - x1) * (x1 - x2));
368 // sum += (x1-x0)*( f0 + 4*f1 + f2 ) / 3.0 for equal spacing
369 }
370 // return the value
371 return sum;
372 }
373
374
375
376 template <>
377 void OneD_Node_Mesh<double, double>::read(std::string filename, bool reset ) {
378 std::ifstream dump;
379 std::cout << "[INFO] Reading OneD_Node_Mesh<double,double> data from " + filename + "\n";
380 dump.open(filename.c_str());
381 if (dump.good() != true) {
382 std::string problem;
383 problem = " The OneD_Node_Mesh.read method is trying to read a \n";
384 problem += " file (" + filename + ") that doesn't exist.\n";
385 throw ExceptionRuntime(problem);
386 }
387 dump.precision(15);
388 dump.setf(std::ios::showpoint);
389 dump.setf(std::ios::showpos);
390 dump.setf(std::ios::scientific);
391 std::size_t N = get_nnodes();
392 for (std::size_t i = 0; i < N; ++i) {
393 double x;
394 dump >> x;
395 for (std::size_t var = 0; var < m_nv; ++var) {
396 double value;
397 dump >> value;
398 m_vars[ i * m_nv + var ] = value;
399 }
400 if (reset != true) {
401 // if not reseting the mesh we should check the node positions
402 if (std::fabs(x - m_X[ i ]) > 1.e-6) {
403 std::cout << " Read x = " << x << " Expected x = " << m_X[ i ] << "\n";
404 std::cout << " Absolute differences are " << fabs(x - m_X[i]) << "\n";
405 std::string problem;
406 problem = " The TwoD_Node_Mesh.read method is trying to read a \n";
407 problem += " file whose nodal points are in a different position. \n";
408 throw ExceptionRuntime(problem);
409 }
410 } else {
411 m_X[ i ] = x;
412 }
413 }
414 }
415
416 template <>
417 void OneD_Node_Mesh<D_complex, double>::read(std::string filename, bool reset ) {
418 std::ifstream dump;
419 std::cout << "[INFO] Reading OneD_Node_Mesh<D_complex,double> data from " + filename + "\n";
420 dump.open(filename.c_str());
421 if (dump.good() != true) {
422 std::string problem;
423 problem = " The OneD_Node_Mesh.read method is trying to read a \n";
424 problem += " file (" + filename + ") that doesn't exist.\n";
425 throw ExceptionRuntime(problem);
426 }
427 dump.precision(15);
428 dump.setf(std::ios::showpoint);
429 dump.setf(std::ios::showpos);
430 dump.setf(std::ios::scientific);
431 std::size_t N = get_nnodes();
432 for (std::size_t i = 0; i < N; ++i) {
433 double x;
434 dump >> x;
435 for (std::size_t var = 0; var < m_nv; ++var) {
436 double rValue, iValue;
437 dump >> rValue; dump >> iValue;
438 m_vars[ i * m_nv + var ] = D_complex(rValue,iValue);
439 }
440 if (reset != true) {
441 // if not reseting the mesh we should check the node positions
442 if (std::fabs(x - m_X[ i ]) > 1.e-6) {
443 std::cout << " Read x = " << x << " Expected x = " << m_X[ i ] << "\n";
444 std::cout << " Absolute differences are " << fabs(x - m_X[i]) << "\n";
445 std::string problem;
446 problem = " The TwoD_Node_Mesh.read method is trying to read a \n";
447 problem += " file whose nodal points are in a different position. \n";
448 throw ExceptionRuntime(problem);
449 }
450 } else {
451 m_X[ i ] = x;
452 }
453 }
454 }
455
456 template <>
457 void OneD_Node_Mesh<D_complex, D_complex>::read(std::string filename, bool reset ) {
458 std::ifstream dump;
459 std::cout << "[INFO] Reading OneD_Node_Mesh<D_complex, D_complex> data from " + filename + "\n";
460 dump.open(filename.c_str());
461 if (dump.good() != true) {
462 std::string problem;
463 problem = " The OneD_Node_Mesh.read method is trying to read a \n";
464 problem += " file (" + filename + ") that doesn't exist.\n";
465 throw ExceptionRuntime(problem);
466 }
467 dump.precision(15);
468 dump.setf(std::ios::showpoint);
469 dump.setf(std::ios::showpos);
470 dump.setf(std::ios::scientific);
471 std::size_t N = get_nnodes();
472 for (std::size_t i = 0; i < N; ++i) {
473 double rX, iX;
474 dump >> rX; dump >> iX;
475 D_complex X(rX,iX);
476 for (std::size_t var = 0; var < m_nv; ++var) {
477 double rValue, iValue;
478 dump >> rValue; dump >> iValue;
479 m_vars[ i * m_nv + var ] = D_complex(rValue,iValue);
480 }
481 if (reset != true) {
482 // if not reseting the mesh we should check the node positions
483 if (std::fabs( X - m_X[ i ]) > 1.e-6) {
484 std::cout << " Read x = " << X << " Expected x = " << m_X[ i ] << "\n";
485 std::cout << " Absolute differences are " << fabs( X - m_X[i]) << "\n";
486 std::string problem;
487 problem = " The TwoD_Node_Mesh.read method is trying to read a \n";
488 problem += " file whose nodal points are in a different position. \n";
489 throw ExceptionRuntime(problem);
490 }
491 } else {
492 m_X[ i ] = X;
493 }
494 }
495 }
496
497
498 template < typename _Type, typename _Xtype >
500 std::cout << "Number of nodes = " << m_X.size() << "\n";
501 std::cout << "Nodal positions :\n";
502 m_X.dump();
503 std::cout << "\n";
504 std::cout << "Number of vars = " << m_nv << "\n";
505 std::cout << "Interleaved mesh data : \n";
506 m_vars.dump();
507 std::cout << "Mesh dump complete\n";
508 }
509
510 template <>
511 void OneD_Node_Mesh<double, double>::dump_gnu(std::string filename, int precision) const {
512 std::ofstream dump;
513 dump.open(filename.c_str());
514 dump.precision(precision);
515 dump.setf(std::ios::showpoint);
516 dump.setf(std::ios::showpos);
517 dump.setf(std::ios::scientific);
518 for(std::size_t i = 0; i < m_X.size(); ++i) {
519 dump << m_X[ i ] << " ";
520 for(std::size_t var = 0; var < m_nv; ++var) {
521 dump << m_vars[ i * m_nv + var ] << " ";
522 }
523 dump << "\n";
524 }
525 }
526
527 template <>
528 void OneD_Node_Mesh< std::complex<double>, double >::dump_gnu(std::string filename, int precision) const {
529 std::ofstream dump;
530 dump.open(filename.c_str());
531 dump.precision(precision);
532 dump.setf(std::ios::showpoint);
533 dump.setf(std::ios::showpos);
534 dump.setf(std::ios::scientific);
535 for(std::size_t i = 0; i < m_X.size(); ++i) {
536 dump << m_X[ i ] << " ";
537 for(std::size_t var = 0; var < m_nv; ++var) {
538 dump << real(m_vars[ i * m_nv + var ]) << " " << imag(m_vars[ i * m_nv + var ]) << " ";
539 }
540 dump << "\n";
541 }
542 }
543
544 template <>
545 void OneD_Node_Mesh< std::complex<double>, std::complex<double> >::dump_gnu(std::string filename, int precision) const {
546 std::ofstream dump;
547 dump.open(filename.c_str());
548 dump.precision(precision);
549 dump.setf(std::ios::showpoint);
550 dump.setf(std::ios::showpos);
551 dump.setf(std::ios::scientific);
552 for(std::size_t i = 0; i < m_X.size(); ++i) {
553 dump << real(m_X[ i ]) << " " << imag(m_X[ i ]) << " ";
554 for(std::size_t var = 0; var < m_nv; ++var) {
555 dump << real(m_vars[ i * m_nv + var ]) << " " << imag(m_vars[ i * m_nv + var ]) << " ";
556 }
557 dump << "\n";
558 }
559 }
560
561
562
563 //the templated versions we require are:
564 template class OneD_Node_Mesh<double>
565 ;
567 ;
568 template class OneD_Node_Mesh<std::complex<double>, std::complex<double> >
569 ;
570}
@ U
Definition: BVPKarman.cpp:20
Specification for a templated DenseVector class – a dense, dynamic, vector object.
The collection of CppNoddy exceptions.
A specification for a one dimensional mesh object.
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
void push_back(const _Type &fill)
A pass-thru definition of push_back.
Definition: DenseVector.h:310
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:330
An exception class to be thrown when a container of incorrect geometry used in any class/method.
Definition: Exceptions.h:47
An exception to indicate that a CppNoddy container has been accessed with index/indices outside the m...
Definition: Exceptions.h:117
A generic runtime exception.
Definition: Exceptions.h:158
A one dimensional mesh utility object.
_Xtype squared_integral2(std::size_t var=0) const
Compute the integral of the absolute variable squared: |variable|^2.
std::size_t get_nvars() const
void set_vars_from_vector(const DenseVector< _Type > &vec)
Set the variables of this mesh from a vector.
const DenseVector< _Xtype > & nodes() const
void read(std::string filename, const bool reset=false)
Assign mesh contents using a filename.
DenseVector< _Type > get_nodes_vars(const std::size_t &node) const
Get the variables stored at A SPECIFIED node.
void dump() const
A simple method for dumping data to std::cout.
DenseVector< _Type > get_interpolated_vars(const _Xtype &pos) const
Get the variable data at an interpolated position using a first order scheme.
void set_nodes_vars(const std::size_t node, const DenseVector< _Type > &u)
Set the variables stored at A SPECIFIED node.
const DenseVector< _Type > & vars_as_vector() const
For each nodal point we push each variable into a vector in sequence.
std::size_t get_nnodes() const
_Type integral4(std::size_t var=0) const
Integrate over the domain with a Simpson rule.
DenseVector< double > find_roots1(const std::size_t &var, double value=0.0) const
Find a list of approximate locations at which a specified variable attains a given value.
_Type integral2(std::size_t var=0) const
Integrate over the domain.
void remesh1(const DenseVector< _Xtype > &z)
Interpolate this mesh data (linearly) into a new mesh with nodal points defined in the argument list.
void dump_gnu(std::string filename, int precision=10) const
A simple method for dumping data to a file for gnuplot.
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