/[escript]/branches/trilinos_from_5897/dudley/src/Mesh_write.cpp
ViewVC logotype

Contents of /branches/trilinos_from_5897/dudley/src/Mesh_write.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6079 - (show annotations)
Mon Mar 21 12:22:38 2016 UTC (2 years, 10 months ago) by caltinay
File size: 6192 byte(s)
Big commit - making dudley much more like finley to make it more
managable. Fixed quite a few issues that had been fixed in finley.
Disposed of all ReducedNode/ReducedDOF entities that dudley never supported.
Compiles and passes tests.

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17 #include "Mesh.h"
18
19 #include <iomanip>
20
21 using std::cout;
22 using std::endl;
23 using std::ios;
24 using std::setw;
25 using std::string;
26
27 namespace dudley {
28
29 // private
30 void Mesh::writeElementInfo(std::ostream& stream, const ElementFile* e,
31 const string& defaultType) const
32 {
33 if (e != NULL) {
34 stream << e->ename << " " << e->numElements << endl;
35 const int NN = e->numNodes;
36 for (index_t i=0; i < e->numElements; i++) {
37 stream << e->Id[i] << " " << e->Tag[i];
38 for (int j=0; j<NN; j++)
39 stream << " " << Nodes->Id[e->Nodes[INDEX2(j,i,NN)]];
40 stream << endl;
41 }
42 } else {
43 stream << defaultType << " 0" << endl;
44 }
45 }
46
47 // private
48 void Mesh::printElementInfo(const ElementFile* e, const string& title,
49 const string& defaultType, bool full) const
50 {
51 if (e != NULL) {
52 dim_t mine=0, overlap=0;
53 for (index_t i=0; i < e->numElements; i++) {
54 if (e->Owner[i] == MPIInfo->rank)
55 mine++;
56 else
57 overlap++;
58 }
59 cout << "\t" << title << ": "
60 << e->ename << " " << e->numElements << " (TypeId=" << e->etype
61 << ") owner=" << mine << " overlap=" << overlap << endl;
62 if (full) {
63 const int NN = e->numNodes;
64 cout << "\t Id Tag Owner Color: Nodes" << endl;
65 for (index_t i=0; i < e->numElements; i++) {
66 cout << "\t" << setw(7) << e->Id[i]
67 << setw(6) << e->Tag[i]
68 << setw(6) << e->Owner[i]
69 << setw(6) << e->Color[i] << ": ";
70 for (int j=0; j<NN; j++)
71 cout << setw(6) << Nodes->Id[e->Nodes[INDEX2(j,i,NN)]];
72 cout << endl;
73 }
74 }
75 } else {
76 cout << "\t" << title << ": " << defaultType << " 0" << endl;
77 }
78 }
79
80
81 void Mesh::write(const std::string& filename) const
82 {
83 if (MPIInfo->size > 1)
84 throw escript::NotImplementedError("Mesh::write: only single rank "
85 "runs are supported.");
86
87 std::ofstream f(filename.c_str());
88 if (!f.is_open()) {
89 std::stringstream ss;
90 ss << "Mesh::write: Opening file " << filename << " for writing failed";
91 throw escript::IOError(ss.str());
92 }
93
94 // write header
95 f << m_name << endl;
96
97 // write nodes
98 if (Nodes != NULL) {
99 const int numDim = getDim();
100 f << numDim << "D-Nodes " << Nodes->getNumNodes() << endl;
101 for (index_t i=0; i<Nodes->getNumNodes(); i++) {
102 f << Nodes->Id[i] << " " << Nodes->globalDegreesOfFreedom[i]
103 << " " << Nodes->Tag[i];
104 f.setf(ios::scientific, ios::floatfield);
105 f.precision(15);
106 for (int j=0; j<numDim; j++)
107 f << " " << Nodes->Coordinates[INDEX2(j,i,numDim)];
108 f << endl;
109 }
110 } else {
111 f << "0D-Nodes 0" << endl;
112 }
113
114 // write elements
115 writeElementInfo(f, Elements, "Tet4");
116
117 // write face elements
118 writeElementInfo(f, FaceElements, "Tri3");
119
120 // write points
121 writeElementInfo(f, Points, "Point1");
122
123 // write tags
124 if (tagMap.size() > 0) {
125 f << "Tags" << endl;
126 TagMap::const_iterator it;
127 for (it=tagMap.begin(); it!=tagMap.end(); it++) {
128 f << it->first << " " << it->second << endl;
129 }
130 }
131 f.close();
132 #ifdef Dudley_TRACE
133 cout << "mesh " << m_name << " has been written to file " << filename << endl;
134 #endif
135 }
136
137 void Mesh::printInfo(bool full)
138 {
139 cout << "PrintMeshInfo running on CPU " << MPIInfo->rank << " of "
140 << MPIInfo->size << endl;
141 cout << "\tMesh name '" << m_name << "'\n";
142 cout << "\tApproximation order " << approximationOrder << endl;
143 cout << "\tIntegration order " << integrationOrder << endl;
144 cout << "\tReduced Integration order " << reducedIntegrationOrder << endl;
145
146 // write nodes
147 if (Nodes != NULL) {
148 const int numDim = getDim();
149 cout << "\tNodes: " << numDim << "D-Nodes " << Nodes->getNumNodes() << endl;
150 if (full) {
151 cout << "\t Id Tag gDOF gNI grDfI grNI: Coordinates\n";
152 for (index_t i=0; i < Nodes->getNumNodes(); i++) {
153 cout << "\t" << setw(7) << Nodes->Id[i]
154 << setw(6) << Nodes->Tag[i]
155 << setw(6) << Nodes->globalDegreesOfFreedom[i]
156 << setw(6) << Nodes->globalNodesIndex[i]
157 << setw(6) << Nodes->globalDegreesOfFreedom[i]
158 << setw(6) << Nodes->globalNodesIndex[i] << ": ";
159 cout.setf(ios::scientific, ios::floatfield);
160 cout.precision(15);
161 for (int j=0; j<numDim; j++)
162 cout << " " << Nodes->Coordinates[INDEX2(j,i,numDim)];
163 cout << endl;
164 }
165 }
166 } else {
167 cout << "\tNodes: 0D-Nodes 0\n";
168 }
169
170 // write elements
171 printElementInfo(Elements, "Elements", "Tet4", full);
172
173 // write face elements
174 printElementInfo(FaceElements, "Face elements", "Tri3", full);
175
176 // write points
177 printElementInfo(Points, "Points", "Point1", full);
178
179 // write tags
180 if (tagMap.size() > 0) {
181 cout << "\tTags:\n";
182 TagMap::const_iterator it;
183 for (it=tagMap.begin(); it!=tagMap.end(); it++) {
184 cout << "\t" << setw(7) << it->second << " " << it->first << endl;
185 }
186 }
187 }
188
189 } // namespace dudley
190

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo /branches/4.0fordebian/dudley/src/Mesh_write.cpp:5567-5588 /branches/lapack2681/finley/src/Mesh_write.cpp:2682-2741 /branches/pasowrap/dudley/src/Mesh_write.cpp:3661-3674 /branches/py3_attempt2/dudley/src/Mesh_write.cpp:3871-3891 /branches/restext/finley/src/Mesh_write.cpp:2610-2624 /branches/ripleygmg_from_3668/dudley/src/Mesh_write.cpp:3669-3791 /branches/stage3.0/finley/src/Mesh_write.cpp:2569-2590 /branches/symbolic_from_3470/dudley/src/Mesh_write.cpp:3471-3974 /branches/symbolic_from_3470/ripley/test/python/dudley/src/Mesh_write.cpp:3517-3974 /release/3.0/finley/src/Mesh_write.cpp:2591-2601 /release/4.0/dudley/src/Mesh_write.cpp:5380-5406 /trunk/dudley/src/Mesh_write.cpp:4257-4344,5898-6007 /trunk/ripley/test/python/dudley/src/Mesh_write.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26