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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Copyright dates update

1 jgs 150
2 jfenwick 3981 /*****************************************************************************
3 ksteube 1811 *
4 jfenwick 6651 * Copyright (c) 2003-2018 by The University of Queensland
5 jfenwick 3981 * http://www.uq.edu.au
6 ksteube 1811 *
7     * Primary Business: Queensland, Australia
8 jfenwick 6112 * Licensed under the Apache License, version 2.0
9     * http://www.apache.org/licenses/LICENSE-2.0
10 ksteube 1811 *
11 jfenwick 3981 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 jfenwick 4657 * Development 2012-2013 by School of Earth Sciences
13     * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 jfenwick 3981 *
15     *****************************************************************************/
16 jgs 82
17 caltinay 6207 #include "FinleyDomain.h"
18 ksteube 1811
19 caltinay 6197 #include <escript/index.h>
20 jgs 82
21 caltinay 5701 #include <iomanip>
22 jfenwick 6076 #include <iostream>
23 caltinay 5701
24     using std::cout;
25     using std::endl;
26     using std::ios;
27     using std::setw;
28 caltinay 5781 using std::string;
29 caltinay 5701
30 caltinay 4496 namespace finley {
31 jgs 82
32 caltinay 5781 // private
33 caltinay 6207 void FinleyDomain::writeElementInfo(std::ostream& stream, const ElementFile* e,
34     const string& defaultType) const
35 caltinay 4496 {
36 caltinay 5781 if (e != NULL) {
37     stream << e->referenceElementSet->referenceElement->Type->Name
38     << " " << e->numElements << endl;
39     const int NN = e->numNodes;
40 caltinay 6207 for (index_t i = 0; i < e->numElements; i++) {
41 caltinay 5781 stream << e->Id[i] << " " << e->Tag[i];
42 caltinay 6207 for (int j = 0; j < NN; j++)
43     stream << " " << m_nodes->Id[e->Nodes[INDEX2(j,i,NN)]];
44 caltinay 5781 stream << endl;
45     }
46     } else {
47     stream << defaultType << " 0" << endl;
48     }
49     }
50    
51     // private
52 caltinay 6207 void FinleyDomain::printElementInfo(const ElementFile* e, const string& title,
53     const string& defaultType, bool full) const
54 caltinay 5781 {
55     if (e != NULL) {
56 caltinay 6207 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 caltinay 5781 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 caltinay 6207 for (index_t i = 0; i < e->numElements; i++) {
72 caltinay 5781 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 caltinay 6207 for (int j = 0; j < NN; j++)
77     cout << setw(6) << m_nodes->Id[e->Nodes[INDEX2(j,i,NN)]];
78 caltinay 5781 cout << endl;
79     }
80     }
81     } else {
82     cout << "\t" << title << ": " << defaultType << " 0" << endl;
83     }
84     }
85    
86 caltinay 6197
87 caltinay 6207 void FinleyDomain::write(const string& filename) const
88 caltinay 5781 {
89 caltinay 6207 if (m_mpiInfo->size > 1)
90     throw escript::NotImplementedError("FinleyDomain::write: only single rank "
91     "runs are supported.");
92 caltinay 5781
93     std::ofstream f(filename.c_str());
94     if (!f.is_open()) {
95     std::stringstream ss;
96 caltinay 6207 ss << "FinleyDomain::write: Opening file " << filename << " for writing failed";
97     throw escript::IOError(ss.str());
98 caltinay 5701 }
99 jgs 82
100 caltinay 5701 // write header
101 caltinay 5781 f << m_name << endl;
102 ksteube 1312
103 caltinay 5781 // write nodes
104 caltinay 6207 if (m_nodes != NULL) {
105 caltinay 5701 const int numDim = getDim();
106 caltinay 6207 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 caltinay 5781 f.setf(ios::scientific, ios::floatfield);
111     f.precision(15);
112 caltinay 6207 for (int j = 0; j < numDim; j++)
113     f << " " << m_nodes->Coordinates[INDEX2(j,i,numDim)];
114 caltinay 5781 f << endl;
115 caltinay 5701 }
116     } else {
117 caltinay 5781 f << "0D-Nodes 0" << endl;
118 caltinay 5701 }
119 jgs 82
120 caltinay 5781 // write elements
121 caltinay 6207 writeElementInfo(f, m_elements, "Tet4");
122 jgs 82
123 caltinay 5781 // write face elements
124 caltinay 6207 writeElementInfo(f, m_faceElements, "Tri3");
125 jgs 82
126 caltinay 5781 // write contact elements
127 caltinay 6207 writeElementInfo(f, m_contactElements, "Tri3_Contact");
128 jgs 82
129 caltinay 5781 // write points
130 caltinay 6207 writeElementInfo(f, m_points, "Point1");
131 gross 1044
132 caltinay 5781 // write tags
133 caltinay 6207 if (m_tagMap.size() > 0) {
134 caltinay 5781 f << "Tags" << endl;
135 caltinay 4437 TagMap::const_iterator it;
136 caltinay 6207 for (it = m_tagMap.begin(); it != m_tagMap.end(); it++) {
137 caltinay 5781 f << it->first << " " << it->second << endl;
138 caltinay 4437 }
139     }
140 caltinay 6207 f << endl;
141 caltinay 5781 f.close();
142 caltinay 4437 #ifdef Finley_TRACE
143 caltinay 5781 cout << "mesh " << m_name << " has been written to file " << filename << endl;
144 caltinay 4437 #endif
145 jgs 82 }
146    
147 caltinay 6207 void FinleyDomain::Print_Mesh_Info(bool full) const
148 caltinay 4437 {
149 caltinay 6207 cout << "PrintMeshInfo running on CPU " << m_mpiInfo->rank << " of "
150     << m_mpiInfo->size << endl;
151 caltinay 5701 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 ksteube 1326
157 caltinay 5781 // write nodes
158 caltinay 6207 if (m_nodes != NULL) {
159 caltinay 5701 const int numDim = getDim();
160 caltinay 6207 cout << "\tNodes: " << numDim << "D-Nodes " << m_nodes->getNumNodes() << endl;
161 caltinay 5701 if (full) {
162     cout << "\t Id Tag gDOF gNI grDfI grNI: Coordinates\n";
163 caltinay 6207 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 caltinay 5701 cout.setf(ios::scientific, ios::floatfield);
171     cout.precision(15);
172 caltinay 6207 for (int j = 0; j < numDim; j++)
173     cout << " " << m_nodes->Coordinates[INDEX2(j,i,numDim)];
174 caltinay 5701 cout << endl;
175     }
176     }
177     } else {
178     cout << "\tNodes: 0D-Nodes 0\n";
179 ksteube 1326 }
180    
181 caltinay 5781 // write elements
182 caltinay 6207 printElementInfo(m_elements, "Elements", "Tet4", full);
183 ksteube 1326
184 caltinay 5781 // write face elements
185 caltinay 6207 printElementInfo(m_faceElements, "Face elements", "Tri3", full);
186 ksteube 1326
187 caltinay 5781 // write contact elements
188 caltinay 6207 printElementInfo(m_contactElements, "Contact elements", "Tri3_Contact", full);
189 ksteube 1326
190 caltinay 5781 // write points
191 caltinay 6207 printElementInfo(m_points, "Points", "Point1", full);
192 ksteube 1326
193 caltinay 4496 // write tags
194 caltinay 6207 if (m_tagMap.size() > 0) {
195 caltinay 5701 cout << "\tTags:\n";
196 caltinay 4437 TagMap::const_iterator it;
197 caltinay 6207 for (it = m_tagMap.begin(); it != m_tagMap.end(); it++) {
198 caltinay 5701 cout << "\t" << setw(7) << it->second << " " << it->first << endl;
199 caltinay 4437 }
200     }
201 ksteube 1326 }
202    
203 caltinay 4496 } // namespace finley
204 jgs 82

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