/[escript]/trunk/finley/src/Mesh_write.cpp
ViewVC logotype

Contents of /trunk/finley/src/Mesh_write.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6651 - (show annotations)
Wed Feb 7 02:12:08 2018 UTC (19 months, 2 weeks ago) by jfenwick
File size: 6894 byte(s)
Make everyone sad by touching all the files

Copyright dates update

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26