CppNoddy  0.92
Loading...
Searching...
No Matches
TwoD_Node_Mesh.cpp
Go to the documentation of this file.
1/// \file TwoD_Node_Mesh.cpp
2/// Implementation of a two dimensional mesh object. Data
3/// is stored on a nodal mesh.
4
5#include <vector>
6#include <fstream>
7#include <iostream>
8#include <iomanip>
9#include <cassert>
10
11#include <Exceptions.h>
12#include <DenseVector.h>
13#include <DenseMatrix.h>
14#include <TwoD_Node_Mesh.h>
15#include <Utility.h>
16
17namespace CppNoddy {
18
19 template <typename _Type>
20 void TwoD_Node_Mesh<_Type>::set_nodes_vars(const std::size_t nodex, const std::size_t nodey, const DenseVector<_Type>& U) {
21#ifdef PARANOID
22 if(U.size() > m_nv) {
23 std::string problem;
24 problem = " The TwoD_Node_Mesh.set_nodes_vars method is trying to use a \n";
25 problem += " vector that has more entries than variables stored in the mesh. \n";
26 throw ExceptionRuntime(problem);
27 }
28#endif
29 // assign contents of U to the member data
30 std::size_t offset((nodex * m_ny + nodey) * m_nv);
31 for(std::size_t var = 0; var < m_nv; ++var) {
32 m_vars[ offset++ ] = U[ var ];
33 }
34 }
35
36 template <typename _Type>
37 DenseVector<_Type> TwoD_Node_Mesh<_Type>::get_nodes_vars(const std::size_t nodex, const std::size_t nodey) const {
38#ifdef PARANOID
39 if(nodex > m_nx - 1 || nodey > m_ny - 1) {
40 std::string problem;
41 problem = " The TwoD_Node_Mesh.get_nodes_vars method is trying to \n";
42 problem += " access a nodal point that is not in the mesh. \n";
43 throw ExceptionRange(problem, m_nx, nodex, m_ny, nodey);
44 }
45#endif
46 // construct a vector with m_nv elements starting from a pointer
47 DenseVector<_Type> nodes_vars(m_nv, &m_vars[(nodex * m_ny + nodey) * m_nv ]);
48 return nodes_vars;
49 }
50
51 template <typename _Type>
52 void TwoD_Node_Mesh<_Type>::assign(const _Type elt) {
53 m_vars.assign(m_nx * m_ny * m_nv, elt);
54 }
55
56 template <typename _Type>
57 std::pair< std::size_t, std::size_t > TwoD_Node_Mesh<_Type>::get_nnodes() const {
58 std::pair< std::size_t, std::size_t > nodes;
59 nodes.first = m_nx;
60 nodes.second = m_ny;
61 return nodes;
62 }
63
64 template <typename _Type>
66 return m_nv;
67 }
68
69 template <typename _Type>
71 return m_X;
72 }
73
74 template <typename _Type>
76 return m_Y;
77 }
78
79 template <typename _Type>
81#ifdef PARANOID
82 if(var > m_nv - 1) {
83 std::string problem;
84 problem = " The TwoD_Node_Mesh.get_var_as_matrix method is trying to use a \n";
85 problem += " variable index bigger than the number of variables in the mesh. \n";
86 throw ExceptionRange(problem, m_nv, var);
87 }
88#endif
89 DenseMatrix<_Type> temp(m_nx, m_ny, 0.0);
90 for(std::size_t i = 0; i < m_nx; ++i) {
91 for(std::size_t j = 0; j < m_ny; ++j) {
92 temp(i, j) = m_vars[(i * m_ny + j) * m_nv + var ];
93 }
94 }
95 return temp;
96 }
97
98 template< typename _Type>
100#ifdef PARANOID
101 // check start & end
102 if(std::abs(m_X[ 0 ] - newX[ 0 ]) > 1.e-10 ||
103 std::abs(m_X[ m_X.size() - 1 ] - newX[ newX.size() - 1 ]) > 1.e-10) {
104 std::string problem;
105 problem = " The TwoD_Node_Mesh.remesh1 method has been called with \n";
106 problem += " a passed X coordinate vector that has different start and/or \n";
107 problem += " end points from the instantiated object. \n";
108 throw ExceptionRuntime(problem);
109 }
110 // check monotonic node positions
111 for(std::size_t i = 0; i < newX.size() - 1; ++i) {
112 if(newX[ i ] >= newX[ i + 1 ]) {
113 std::string problem;
114 problem = " The TwoD_Node_Mesh.remesh1 method has been passed \n";
115 problem += " a non-monotonic X coordinate vector. \n";
116 problem += Utility::stringify(newX[ i ], 6) + " vs. " + Utility::stringify(newX[ i + 1 ], 6);
117 throw ExceptionRuntime(problem);
118 }
119 }
120 // check start and end
121 if(std::abs(m_Y[ 0 ] - newY[ 0 ]) > 1.e-10 ||
122 std::abs(m_Y[ m_Y.size() - 1 ] - newY[ newY.size() - 1 ]) > 1.e-10) {
123 std::string problem;
124 problem = " The TwoD_Node_Mesh.remesh1 method has been called with \n";
125 problem += " a passed Y coordinate vector that has different start and/or \n";
126 problem += " end points from the instantiated object. \n";
127 throw ExceptionRuntime(problem);
128 }
129 // check monotonic node positions
130 for(std::size_t i = 0; i < newY.size() - 1; ++i) {
131 if(newY[ i ] >= newY[ i + 1 ]) {
132 std::string problem;
133 problem = " The TwoD_Node_Mesh.remesh1 method has been passed \n";
134 problem += " a non-monotonic Y coordinate vector. \n";
135 problem += Utility::stringify(newY[ i ], 6) + " vs. " + Utility::stringify(newY[ i + 1 ], 6);
136 throw ExceptionRuntime(problem);
137 }
138 }
139#endif
140
141 // new variables storage
142 DenseVector<_Type> newvars(newX.size() * newY.size() * m_nv, 0.0);
143
144 // left boundary
145 {
146 std::size_t xnode(0);
147 // bottom left corner copy
148 for(unsigned var = 0; var < m_nv; ++var) {
149 newvars[(xnode * newY.size() + 0) * m_nv + var ] = get_nodes_vars(0, 0)[ var ];
150 }
151 for(std::size_t ynode = 1; ynode < newY.size() - 1; ++ynode) {
152 std::size_t left_i(0); // bracketing index
153 std::size_t below_j(0); // bracketing index
154 double deltaY(0.0);
155 // loop through the source mesh and find the bracket-nodes
156 for(std::size_t j = 0; j < m_Y.size() - 1; ++j) {
157 if((m_Y[ j ] <= newY[ ynode ]) && (newY[ ynode ] < m_Y[ j + 1 ])) {
158 below_j = j;
159 deltaY = newY[ ynode ] - m_Y[ j ];
160 }
161 }
162 DenseVector<_Type> dvarsdY = (get_nodes_vars(left_i, below_j + 1) - get_nodes_vars(left_i, below_j))
163 / (coord(left_i, below_j + 1).second - coord(left_i, below_j).second);
164 DenseVector<_Type> interpolated_vars = get_nodes_vars(left_i, below_j) + dvarsdY * deltaY;
165 for(unsigned var = 0; var < m_nv; ++var) {
166 newvars[(xnode * newY.size() + ynode) * m_nv + var ] = interpolated_vars[ var ];
167 }
168 }
169 // top left corner copy
170 for(unsigned var = 0; var < m_nv; ++var) {
171 newvars[(xnode * newY.size() + newY.size() - 1) * m_nv + var ] = get_nodes_vars(0, m_ny - 1)[ var ];
172 }
173 }
174 // right boundary
175 {
176 std::size_t xnode(newX.size() - 1);
177 // bottom right corner copy
178 for(unsigned var = 0; var < m_nv; ++var) {
179 newvars[(xnode * newY.size() + 0) * m_nv + var ] = get_nodes_vars(m_nx - 1, 0)[ var ];
180 }
181 for(std::size_t ynode = 1; ynode < newY.size() - 1; ++ynode) {
182 std::size_t left_i(m_X.size() - 1); // bracketing index
183 std::size_t below_j(0); // bracketing index
184 double deltaY(0.0);
185 // loop through the source mesh and find the bracket-nodes
186 for(std::size_t j = 0; j < m_Y.size() - 1; ++j) {
187 if((m_Y[ j ] <= newY[ ynode ]) && (newY[ ynode ] < m_Y[ j + 1 ])) {
188 below_j = j;
189 deltaY = newY[ ynode ] - m_Y[ j ];
190 }
191 }
192 DenseVector<_Type> dvarsdY = (get_nodes_vars(left_i, below_j + 1) - get_nodes_vars(left_i, below_j))
193 / (coord(left_i, below_j + 1).second - coord(left_i, below_j).second);
194 DenseVector<_Type> interpolated_vars = get_nodes_vars(left_i, below_j) + dvarsdY * deltaY;
195 for(unsigned var = 0; var < m_nv; ++var) {
196 newvars[(xnode * newY.size() + ynode) * m_nv + var ] = interpolated_vars[ var ];
197 }
198 }
199 // bottom right corner copy
200 for(unsigned var = 0; var < m_nv; ++var) {
201 newvars[(xnode * newY.size() + newY.size() - 1) * m_nv + var ] = get_nodes_vars(m_nx - 1, m_ny - 1)[ var ];
202 }
203 }
204 // bottom boundary
205 {
206 std::size_t ynode(0);
207 for(std::size_t xnode = 1; xnode < newX.size() - 1; ++xnode) {
208 std::size_t left_i(0); // bracketing index
209 std::size_t below_j(0); // bracketing index
210 double deltaX(0.0);
211 // loop through the source mesh and find the bracket-nodes
212 for(std::size_t i = 0; i < m_X.size() - 1; ++i) {
213 if((m_X[ i ] <= newX[ xnode ]) && (newX[ xnode ] < m_X[ i + 1 ])) {
214 left_i = i;
215 deltaX = newX[ xnode ] - m_X[ i ];
216 }
217 }
218 DenseVector<_Type> dvarsdX = (get_nodes_vars(left_i + 1, below_j) - get_nodes_vars(left_i, below_j))
219 / (coord(left_i + 1, below_j).first - coord(left_i, below_j).first);
220 DenseVector<_Type> interpolated_vars = get_nodes_vars(left_i, below_j) + dvarsdX * deltaX;
221 for(unsigned var = 0; var < m_nv; ++var) {
222 newvars[(xnode * newY.size() + ynode) * m_nv + var ] = interpolated_vars[ var ];
223 }
224 }
225 }
226 // top boundary
227 {
228 std::size_t ynode(newY.size() - 1);
229 for(std::size_t xnode = 1; xnode < newX.size() - 1; ++xnode) {
230 std::size_t left_i(0); // bracketing index
231 std::size_t below_j(m_Y.size() - 1); // bracketing index
232 double deltaX(0.0);
233 // loop through the source mesh and find the bracket-nodes
234 for(std::size_t i = 0; i < m_X.size() - 1; ++i) {
235 if((m_X[ i ] <= newX[ xnode ]) && (newX[ xnode ] < m_X[ i + 1 ])) {
236 left_i = i;
237 deltaX = newX[ xnode ] - m_X[ i ];
238 }
239 }
240 DenseVector<_Type> dvarsdX = (get_nodes_vars(left_i + 1, below_j) - get_nodes_vars(left_i, below_j))
241 / (coord(left_i + 1, below_j).first - coord(left_i, below_j).first);
242 DenseVector<_Type> interpolated_vars = get_nodes_vars(left_i, below_j) + dvarsdX * deltaX;
243 for(unsigned var = 0; var < m_nv; ++var) {
244 newvars[(xnode * newY.size() + ynode) * m_nv + var ] = interpolated_vars[ var ];
245 }
246 }
247 }
248 // loop thru interior nodes of the destination mesh one node at a time
249 for(std::size_t xnode = 1; xnode < newX.size() - 1; ++xnode) {
250 for(std::size_t ynode = 1; ynode < newY.size() - 1; ++ynode) {
251 std::size_t left_i(0); // bracketing index
252 std::size_t below_j(0); // bracketing index
253 // loop through the source mesh and find the bracket-nodes
254 for(std::size_t i = 0; i < m_X.size() - 1; ++i) {
255 if((m_X[ i ] <= newX[ xnode ]) && (newX[ xnode ] < m_X[ i + 1 ])) {
256 left_i = i;
257 }
258 }
259 // loop through the source mesh and find the bracket-nodes
260 for(std::size_t j = 0; j < m_Y.size() - 1; ++j) {
261 if((m_Y[ j ] <= newY[ ynode ]) && (newY[ ynode ] < m_Y[ j + 1 ])) {
262 below_j = j;
263 }
264 }
265 DenseVector<_Type> dvarsdX = (get_nodes_vars(left_i + 1, below_j) - get_nodes_vars(left_i, below_j))
266 / (coord(left_i + 1, below_j).first - coord(left_i, below_j).first);
267 DenseVector<_Type> dvarsdY = (get_nodes_vars(left_i, below_j + 1) - get_nodes_vars(left_i, below_j))
268 / (coord(left_i, below_j + 1).second - coord(left_i, below_j).second);
269
270 DenseVector<_Type> interpolated_vars_bottom =
271 (get_nodes_vars(left_i, below_j) * (coord(left_i + 1, below_j).first - newX[ xnode ])
272 + get_nodes_vars(left_i + 1, below_j) * (newX[ xnode ] - coord(left_i, below_j).first)) /
273 (coord(left_i + 1, below_j).first - coord(left_i, below_j).first);
274
275 DenseVector<_Type> interpolated_vars_top =
276 (get_nodes_vars(left_i, below_j + 1) * (coord(left_i + 1, below_j + 1).first - newX[ xnode ])
277 + get_nodes_vars(left_i + 1, below_j + 1) * (newX[ xnode ] - coord(left_i, below_j + 1).first)) /
278 (coord(left_i + 1, below_j + 1).first - coord(left_i, below_j + 1).first);
279
280 DenseVector<_Type> interpolated_vars =
281 (interpolated_vars_bottom * (coord(left_i, below_j + 1).second - newY[ ynode ])
282 + interpolated_vars_top * (newY[ ynode ] - coord(left_i, below_j).second)) /
283 (coord(left_i, below_j + 1).second - coord(left_i, below_j).second);
284
285 for(unsigned var = 0; var < m_nv; ++var) {
286 newvars[(xnode * newY.size() + ynode) * m_nv + var ] = interpolated_vars[ var ];
287 }
288 }
289 }
290 // finally replace the old nodes with the new ones
291 m_X = newX;
292 m_Y = newY;
293 m_nx = newX.size();
294 m_ny = newY.size();
295 m_vars = newvars;
296 }
297
298 template<typename _Type>
300 OneD_Node_Mesh<_Type> xsection(m_Y, m_nv);
301 for(std::size_t nodey = 0; nodey < m_ny; ++nodey) {
302 xsection.set_nodes_vars(nodey, this -> get_nodes_vars(nodex, nodey));
303 }
304 return xsection;
305 }
306
307 template<typename _Type>
309 OneD_Node_Mesh<_Type> xsection(m_X, m_nv);
310 for(std::size_t nodex = 0; nodex < m_nx; ++nodex) {
311 xsection.set_nodes_vars(nodex, this -> get_nodes_vars(nodex, nodey));
312 }
313 return xsection;
314 }
315
316
317 template <typename _Type>
319 for(std::size_t var = 0; var < m_nv; ++var) {
320 std::cout << "Variable : " << var << "\n";
321 std::cout << " x = ";
322 for(std::size_t i = 0; i < m_nx; ++i) {
323 std::cout << m_X[ i ] << ", ";
324 }
325
326 std::cout << "\n";
327 for(std::size_t j = 0; j < m_ny; ++j) {
328 std::cout << " y = " << m_Y[ j ] << "\n";
329 for(std::size_t i = 0; i < m_nx; ++i) {
330 std::cout << m_vars[(i * m_ny + j) * m_nv + var ] << ", ";
331 }
332 std::cout << "\n";
333 }
334 }
335 }
336
337
338 template<>
339 void TwoD_Node_Mesh<double>::normalise(const std::size_t& var) {
340 double maxval(max_abs(var));
341 m_vars.scale(1./maxval);
342 }
343
344 template<>
345 void TwoD_Node_Mesh<D_complex>::normalise(const std::size_t& var) {
346 unsigned max_nx(0);
347 unsigned max_ny(0);
348 double max(0.0);
349 // step through the nodes
350 for(unsigned nodex = 0; nodex < m_X.size(); ++nodex) {
351 for(unsigned nodey = 0; nodey < m_Y.size(); ++nodey) {
352 if(std::abs(m_vars[(nodex * m_ny + nodey) * m_nv + var ]) > max) {
353 max = std::abs(m_vars[(nodex * m_ny + nodey) * m_nv + var ]);
354 max_nx = nodex;
355 max_ny = nodey;
356 }
357 }
358 }
359 D_complex factor(m_vars[(max_nx * m_ny + max_ny) * m_nv + var ]);
360 std::cout << "[DEBUG] Normalise factor = " << factor << "\n";
361 m_vars.scale(1./factor);
362 // D_complex max_elt = m_vars[(max_nx * m_ny + max_ny) * m_nv + var ];
363 // std::cout << "[DEBUG] Normalise max_elt = " << max_elt << "\n";
364 // // to here will give |variable|=1 but in general v_r and v+i .ne. 0
365 // // additionally we can scale by a factor of unit magnitude
366 // // in order to make v_r=1 and v_i=0.
367 // m_vars.scale( std::conj(max_elt) );
368 // std::cout << "[DEBUG] Normalise max_elt = " << m_vars[(max_nx * m_ny + max_ny) * m_nv + var ] << "\n";
369 }
370
371 // specialised because obviously a double mesh element won't be able
372 // to call the .real() method.
373 template<>
375 double max(0.0);
376 // step through the nodes
377 for(unsigned nodex = 0; nodex < m_X.size(); ++nodex) {
378 for(unsigned nodey = 0; nodey < m_Y.size(); ++nodey) {
379 if(std::abs(m_vars[(nodex * m_ny + nodey) * m_nv + var ].real()) > max) {
380 max = std::abs(m_vars[(nodex * m_ny + nodey) * m_nv + var ].real());
381 }
382 }
383 }
384 return max;
385 }
386
387 template<>
389#ifdef PARANOID
390 // check start & end
391 std::string problem;
392 problem = " The TwoD_Node_Mesh.max_abs_real_part method has been called for \n";
393 problem += " a mesh with element type of double (rather than D_complex).";
394 throw ExceptionRuntime(problem);
395#endif
396 // just call the max_abs
397 return max_abs(var);
398 }
399
400 template<>
401 void TwoD_Node_Mesh<double>::dump_gnu(std::string filename) const {
402 std::ofstream dump;
403 dump.open(filename.c_str());
404 dump.precision(15);
405 dump.setf(std::ios::showpoint);
406 dump.setf(std::ios::showpos);
407 dump.setf(std::ios::scientific);
408 //
409 for(std::size_t i = 0; i < m_nx; ++i) {
410 for(std::size_t j = 0; j < m_ny; ++j) {
411 dump << m_X[ i ] << " " << m_Y[ j ] << " ";
412 for(std::size_t var = 0; var < m_nv; ++var) {
413 dump << m_vars[(i * m_ny + j) * m_nv + var ] << " ";
414 }
415 dump << "\n";
416 }
417 dump << "\n";
418 }
419 dump.close();
420 }
421
422 template <>
423 void TwoD_Node_Mesh<D_complex>::dump_gnu(std::string filename) const {
424 std::ofstream dump;
425 dump.open(filename.c_str());
426 dump.precision(15);
427 dump.setf(std::ios::showpoint);
428 dump.setf(std::ios::showpos);
429 dump.setf(std::ios::scientific);
430 //
431 for(std::size_t i = 0; i < m_nx; ++i) {
432 for(std::size_t j = 0; j < m_ny; ++j) {
433 dump << m_X[ i ] << " " << m_Y[ j ] << " ";
434 for(std::size_t var = 0; var < m_nv; ++var) {
435 dump << real(m_vars[(i * m_ny + j) * m_nv + var ]) << " ";
436 dump << imag(m_vars[(i * m_ny + j) * m_nv + var ]) << " ";
437 }
438 dump << "\n";
439 }
440 dump << "\n";
441 }
442 dump.close();
443 }
444
445 template< typename _Type>
446 void TwoD_Node_Mesh<_Type>::dump_var(std::string filename, const unsigned var) const {
447 std::ofstream dump;
448 dump.open(filename.c_str());
449 dump.precision(15);
450 dump.setf(std::ios::showpoint);
451 dump.setf(std::ios::showpos);
452 dump.setf(std::ios::scientific);
453 for(std::size_t i = 0; i < m_nx; ++i) {
454 for(std::size_t j = 0; j < m_ny; ++j) {
455 dump << m_vars[(i * m_ny + j) * m_nv + var ] << "\n";
456 }
457 }
458 }
459
460 template< typename _Type>
461 void TwoD_Node_Mesh<_Type>::dump(std::string filename) const {
462 std::ofstream dump;
463 dump.open(filename.c_str());
464 dump.precision(15);
465 dump.setf(std::ios::showpoint);
466 dump.setf(std::ios::showpos);
467 dump.setf(std::ios::scientific);
468 //dump << m_nx << " " << m_ny << " " << m_nv << "\n";
469 dump.precision(9);
470 for(std::size_t i = 0; i < m_nx; ++i) {
471 for(std::size_t j = 0; j < m_ny; ++j) {
472 dump << m_X[ i ] << " " << m_Y[ j ] << " ";
473 for(std::size_t var = 0; var < m_nv; ++var) {
474 dump << m_vars[(i * m_ny + j) * m_nv + var ] << " ";
475 }
476 dump << "\n";
477 }
478 }
479 }
480
481 template<>
482 void TwoD_Node_Mesh<double>::read(std::string filename, bool reset) {
483 std::ifstream dump;
484 dump.open(filename.c_str());
485 if(dump.good() != true) {
486 std::string problem;
487 problem = " The TwoD_Node_Mesh.read method is trying to read a \n";
488 problem += " file (" + filename + ") that doesn't exist.\n";
489 throw ExceptionRuntime(problem);
490 }
491 dump.precision(15);
492 dump.setf(std::ios::showpoint);
493 dump.setf(std::ios::showpos);
494 dump.setf(std::ios::scientific);
495 for(std::size_t i = 0; i < m_nx; ++i) {
496 for(std::size_t j = 0; j < m_ny; ++j) {
497 double x, y;
498 dump >> x;
499 dump >> y;
500 for(std::size_t var = 0; var < m_nv; ++var) {
501 double value;
502 dump >> value;
503 m_vars[(i * m_ny + j) * m_nv + var ] = value;
504 }
505 if(reset != true) {
506 // if not reseting the mesh we should check the node positions
507 if((std::fabs(x - m_X[ i ]) > 1.e-6) || (std::fabs(y - m_Y[ j ]) > 1.e-6)) {
508 std::cout << " Read x = " << x << " Expected x = " << m_X[ i ] << "; Read y = " << y << " Expected y = " << m_Y[ j ] << " \n";
509 std::cout << " Absolute differences are " << fabs(x - m_X[i]) << " and " << fabs(y - m_Y[j]) << "\n";
510 std::string problem;
511 problem = " The TwoD_Node_Mesh.read method is trying to read a \n";
512 problem += " file whose nodal points are in a different position. \n";
513 throw ExceptionRuntime(problem);
514 }
515 } else {
516 m_X[ i ] = x;
517 m_Y[ j ] = y;
518 }
519 }
520 }
521 }
522
523
524 template<>
525 void TwoD_Node_Mesh<D_complex>::read(std::string filename, bool reset) {
526 std::ifstream dump;
527 dump.open(filename.c_str());
528 dump.precision(15);
529 dump.setf(std::ios::showpoint);
530 dump.setf(std::ios::showpos);
531 dump.setf(std::ios::scientific);
532 //
533 // 18/06/2017: switched i and j below for consistency with double
534 //
535 for(std::size_t i = 0; i < m_nx; ++i) {
536 for(std::size_t j = 0; j < m_ny; ++j) {
537 double x, y;
538 dump >> x;
539 dump >> y;
540 for(std::size_t var = 0; var < m_nv; ++var) {
541 double value_r, value_i;
542 dump >> value_r;
543 dump >> value_i;
544 m_vars[(i * m_ny + j) * m_nv + var ] = D_complex(value_r, value_i);
545 }
546 if(reset != true) {
547 // if not reseting the mesh we should check the node positions
548 if((std::fabs(x - m_X[ i ]) > 1.e-6) || (std::fabs(y - m_Y[ j ]) > 1.e-6)) {
549 std::cout << " Read x = " << x << " Expected x = " << m_X[ i ] << "; Read y = " << y << " Expected y = " << m_Y[ j ] << " \n";
550 std::cout << " Absolute differences are " << fabs(x - m_X[i]) << " and " << fabs(y - m_Y[j]) << "\n";
551 std::string problem;
552 problem = " The TwoD_Node_Mesh.read method is trying to read a \n";
553 problem += " file whose nodal points are in a different position. \n";
554 throw ExceptionRuntime(problem);
555 }
556 } else {
557 m_X[ i ] = x;
558 m_Y[ j ] = y;
559 }
560 }
561 }
562 }
563
564 //the templated versions we require are:
565 template class TwoD_Node_Mesh<double>
566 ;
568 ;
569
570}
@ U
Definition: BVPKarman.cpp:20
A matrix class that constructs a DENSE matrix as an STL Vector of DenseVectors.
Specification for a templated DenseVector class – a dense, dynamic, vector object.
The collection of CppNoddy exceptions.
A specification for a two dimensional mesh object.
A spec for a collection of utility functions.
A matrix class that constructs a DENSE matrix as a row major std::vector of DenseVectors.
Definition: DenseMatrix.h:25
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:330
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.
void set_nodes_vars(const std::size_t node, const DenseVector< _Type > &u)
Set the variables stored at A SPECIFIED node.
A two dimensional mesh utility object.
std::pair< std::size_t, std::size_t > get_nnodes() const
Get the number of nodes in the two directions of the 2D mesh.
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...
const DenseVector< double > & xnodes() const
Access the vector of x-nodal positions.
OneD_Node_Mesh< _Type > get_xsection_at_xnode(const std::size_t nodex) const
Get a cross section of the 2D mesh at a specified (constant) x node.
void assign(const _Type elt)
Assign an element to all entries in the mesh.
double max_abs_real_part(unsigned var)
Find the maximum stored absolute value in the mesh for a given variable – no interpolation is used.
void read(std::string filename, const bool reset=false)
A simple method for reading data from a file.
void normalise(const std::size_t &var)
Normalise all data in the mesh based on one variable.
DenseVector< _Type > get_nodes_vars(const std::size_t nodex, const std::size_t nodey) const
Get the variables stored at A SPECIFIED node – equivalent to mesh(nodex,nodey).
std::size_t get_nvars() const
Get the number of variables that are stored at each node.
const DenseVector< double > & ynodes() const
Access the vector of y-nodal positions.
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...
void dump_gnu(std::string filename) const
A simple method for dumping data to a file for gnuplot surface plotting.
void dump_var(std::string filename, const unsigned var) const
A simple method for dumping a single variable to a file with no nodal information.
void dump() const
A simple method for dumping data to std::cout.
OneD_Node_Mesh< _Type > get_xsection_at_ynode(const std::size_t nodey) const
Get a cross section of the 2D mesh at a specified (constant) y node.
void set_nodes_vars(const std::size_t nodex, const std::size_t nodey, const DenseVector< _Type > &U)
Set the variables stored at A SPECIFIED node.
std::string stringify(const int &val)
Return an integer value as a string - useful for file naming.
Definition: Utility.cpp:193
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