Directory: | ./ |
---|---|
File: | InputOutput/ensight.cpp |
Date: | 2024-04-14 07:32:34 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 757 | 1359 | 55.7% |
Branches: | 714 | 2480 | 28.8% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // ______ ______ _ _ _____ ______ | ||
2 | // | ____| ____| | (_)/ ____| | ____| | ||
3 | // | |__ | |__ | | _| (___ ___| |__ | ||
4 | // | __| | __| | | | |\___ \ / __| __| | ||
5 | // | | | |____| |____| |____) | (__| |____ | ||
6 | // |_| |______|______|_|_____/ \___|______| | ||
7 | // Finite Elements for Life Sciences and Engineering | ||
8 | // | ||
9 | // License: LGL2.1 License | ||
10 | // FELiScE default license: LICENSE in root folder | ||
11 | // | ||
12 | // Main authors: J.Castelneau & J.Foulon | ||
13 | // | ||
14 | |||
15 | /*! | ||
16 | \file ensight.cpp | ||
17 | \authors J.Castelneau & J.Foulon | ||
18 | \date 04/05/2010 | ||
19 | \brief File containing implementation of object to use Ensight software | ||
20 | */ | ||
21 | |||
22 | // System includes | ||
23 | |||
24 | // External includes | ||
25 | |||
26 | // Project includes | ||
27 | #include "InputOutput/ensight.hpp" | ||
28 | #include "Geometry/geometricMeshRegion.hpp" | ||
29 | #include "Core/util_string.hpp" | ||
30 | #include "Core/felisceTools.hpp" | ||
31 | |||
32 | namespace felisce | ||
33 | { | ||
34 | // Ensight Class | ||
35 | //============== | ||
36 | Ensight::StringToEns6Pair_type Ensight::m_eltFelNameToEns6Pair; | ||
37 | Ensight::StringToElementType_type Ensight::m_eltEns6NameToEnum; | ||
38 | |||
39 | /*! Initialisation of static std::unordered_map useful to manage mesh name */ | ||
40 | 1077 | void Ensight::initMap() | |
41 | { | ||
42 | //std::unordered_map for ensight6 mesh: | ||
43 | //felisce type name -> < enum, ensight6 name > | ||
44 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Nodes"] = std::make_pair( GeometricMeshRegion::Nod, "point" ); |
45 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Segments2"] = std::make_pair( GeometricMeshRegion::Seg2, "bar2" ); |
46 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Segments3b"] = std::make_pair( GeometricMeshRegion::Seg3b, "null1" ); |
47 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Segments3"] = std::make_pair( GeometricMeshRegion::Seg3, "bar3" ); |
48 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Triangles3"] = std::make_pair( GeometricMeshRegion::Tria3, "tria3" ); |
49 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Triangles4"] = std::make_pair( GeometricMeshRegion::Tria4, "null2" ); |
50 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Triangles6"] = std::make_pair( GeometricMeshRegion::Tria6, "tria6" ); |
51 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Quadrangles4"] = std::make_pair( GeometricMeshRegion::Quad4, "quad4" ); |
52 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Quadrangles5"] = std::make_pair( GeometricMeshRegion::Quad5, "null3" ); |
53 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Quadrangles6"] = std::make_pair( GeometricMeshRegion::Quad6, "null4" ); |
54 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Quadrangles8"] = std::make_pair( GeometricMeshRegion::Quad8, "quad8" ); |
55 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Quadrangles9"] = std::make_pair( GeometricMeshRegion::Quad9, "null5" ); |
56 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Tetrahedra4"] = std::make_pair( GeometricMeshRegion::Tetra4, "tetra4" ); |
57 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Tetrahedra5"] = std::make_pair( GeometricMeshRegion::Tetra5, "null6" ); |
58 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Tetrahedra10"] = std::make_pair( GeometricMeshRegion::Tetra10,"tetra10" ); |
59 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Pyramids5"] = std::make_pair( GeometricMeshRegion::Pyram5, "pyramid5" ); |
60 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Pyramids13"] = std::make_pair( GeometricMeshRegion::Pyram13,"pyramid13" ); |
61 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Prisms6"] = std::make_pair( GeometricMeshRegion::Prism6, "penta6" ); |
62 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Prisms9"] = std::make_pair( GeometricMeshRegion::Prism9, "null7" ); |
63 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Prisms15"] = std::make_pair( GeometricMeshRegion::Prism15,"penta15" ); |
64 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Hexahedra8"] = std::make_pair( GeometricMeshRegion::Hexa8, "hexa8" ); |
65 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Hexahedra9"] = std::make_pair( GeometricMeshRegion::Hexa9, "null8" ); |
66 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Hexahedra20"] = std::make_pair( GeometricMeshRegion::Hexa20, "hexa20" ); |
67 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Hexahedra26"] = std::make_pair( GeometricMeshRegion::Hexa26, "null9" ); |
68 |
4/8✓ Branch 1 taken 1077 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1077 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1077 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1077 times.
✗ Branch 12 not taken.
|
1077 | m_eltFelNameToEns6Pair["Hexahedra27"] = std::make_pair( GeometricMeshRegion::Hexa27, "null10" ); |
69 | |||
70 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1077 times.
|
1077 | FEL_CHECK((unsigned int)GeometricMeshRegion::m_numTypesOfElement == m_eltFelNameToEns6Pair.size(), "Error: incompatibility between ElementType enum and ensight std::unordered_map."); |
71 | |||
72 | ElementType eltType; | ||
73 | //reverse the std::unordered_map | ||
74 | //ensight6 name -> enum | ||
75 |
2/2✓ Branch 0 taken 26925 times.
✓ Branch 1 taken 1077 times.
|
28002 | for (int ityp=0; ityp<GeometricMeshRegion::m_numTypesOfElement; ityp++ ) { |
76 | 26925 | eltType = (ElementType)ityp; | |
77 | 26925 | m_eltEns6NameToEnum[ m_eltFelNameToEns6Pair[ GeometricMeshRegion::eltEnumToFelNameGeoEle[eltType].first ].second ] = eltType; | |
78 | } | ||
79 | 1077 | } | |
80 | |||
81 | /***********************************************************************************/ | ||
82 | /***********************************************************************************/ | ||
83 | |||
84 | /*! Ensigt object build mesh information \todo and Variable */ | ||
85 | 22 | Ensight::Ensight(const std::string& inputDirectory,const std::string& inputFile,const std::string& inputMesh,const std::string& outputMesh,const std::string& meshDir,const std::string& resultDir) : | |
86 | 22 | m_indexStep(0), | |
87 |
1/2✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
|
22 | m_inputDirectory(inputDirectory), |
88 |
1/2✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
|
22 | m_inputFile(inputFile), |
89 |
1/2✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
|
22 | m_inputMesh(inputMesh), |
90 |
1/2✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
|
22 | m_outputMesh(outputMesh), |
91 |
1/2✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
|
22 | m_meshDir(meshDir), |
92 |
3/6✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 22 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 22 times.
✗ Branch 9 not taken.
|
44 | m_resultDir(resultDir) |
93 | { | ||
94 |
1/2✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
|
22 | initMap(); |
95 | 22 | m_domainDim = 0; | |
96 | 22 | m_createNormalTangent = false; | |
97 | 22 | } | |
98 | |||
99 | /***********************************************************************************/ | ||
100 | /***********************************************************************************/ | ||
101 | |||
102 | 1055 | void Ensight::initialize(const std::string& inputDirectory,const std::string& inputFile,const std::string& inputMesh,const std::string& outputMesh,const std::string& meshDir,const std::string& resultDir) | |
103 | { | ||
104 | 1055 | m_indexStep = 0; | |
105 | 1055 | m_inputDirectory = inputDirectory; | |
106 | 1055 | m_inputFile = inputFile; | |
107 | 1055 | m_inputMesh = inputMesh; | |
108 | 1055 | m_outputMesh = outputMesh; | |
109 | 1055 | m_meshDir = meshDir; | |
110 | 1055 | m_resultDir = resultDir; | |
111 | 1055 | initMap(); | |
112 | 1055 | } | |
113 | |||
114 | /***********************************************************************************/ | ||
115 | /***********************************************************************************/ | ||
116 | |||
117 | 995 | void Ensight::initializeOutput(const std::string& nameGeoFile,int time_set, | |
118 | int num_steps,int filename_start_number, | ||
119 | int filename_increment ) | ||
120 | { | ||
121 | 995 | m_caseOutput.initialize(nameGeoFile,time_set,num_steps,filename_start_number, | |
122 | filename_increment); | ||
123 | 995 | } | |
124 | |||
125 | /***********************************************************************************/ | ||
126 | /***********************************************************************************/ | ||
127 | |||
128 | ✗ | void Ensight::setResultDir(const std::string resultDir) | |
129 | { | ||
130 | ✗ | m_resultDir=resultDir; | |
131 | } | ||
132 | |||
133 | /***********************************************************************************/ | ||
134 | /***********************************************************************************/ | ||
135 | |||
136 | //! It reads ENSIGHT geo file in directory | ||
137 | //! \todo manage verbose | ||
138 | 11 | void Ensight::readerGeo(GeometricMeshRegion& mesh, double spaceUnit) | |
139 | { | ||
140 | 11 | std::string fileNameGeo, fileNameRoot, fileName; | |
141 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | fileNameGeo = m_inputMesh; //name of the geo file |
142 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | fileNameRoot = m_meshDir; //directory where is the geo file |
143 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | fileName = fileNameRoot + fileNameGeo; //localize the geo file |
144 | |||
145 | 11 | std::string idKeyVert; | |
146 | 11 | std::string idKeyEle; | |
147 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | short verbose = FelisceParam::verbose(); |
148 | |||
149 |
5/8✓ Branch 0 taken 4 times.
✓ Branch 1 taken 7 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
|
11 | if (verbose>0) std::cout << "Reading from file "<< fileName << std::endl; |
150 | |||
151 | // first scan of the mesh vertices | ||
152 | FILE *pFile; | ||
153 |
1/2✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
|
11 | pFile = fopen( fileName.c_str(),"r" ); |
154 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
|
11 | if (pFile==nullptr) { |
155 | ✗ | FEL_ERROR("Impossible to read file: "+fileName+" geo mesh"); | |
156 | } | ||
157 | |||
158 | int tmp; | ||
159 | char tmpIdKey[128]; | ||
160 | 11 | int cpt_line = 0; | |
161 | fpos_t startEltPos; | ||
162 | //skip description lines. | ||
163 |
2/2✓ Branch 0 taken 308 times.
✓ Branch 1 taken 11 times.
|
319 | while (cpt_line < 2 ) { |
164 |
1/2✓ Branch 1 taken 308 times.
✗ Branch 2 not taken.
|
308 | tmp = fgetc(pFile); |
165 |
2/2✓ Branch 0 taken 22 times.
✓ Branch 1 taken 286 times.
|
308 | if ( tmp == '\n' ) |
166 | 22 | cpt_line ++; | |
167 | } | ||
168 | // get idkeys <off/given/assign/ignore> to describe nodes & elements ids | ||
169 |
2/4✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
|
11 | if ( fscanf( pFile, "%s %s %s",tmpIdKey, tmpIdKey, tmpIdKey ) != 3 ) { |
170 | ✗ | FEL_WARNING("Failed to read tmpIdKey"); | |
171 | } | ||
172 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | idKeyVert = tmpIdKey; |
173 |
2/4✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
|
11 | if ( fscanf( pFile, "%s %s %s",tmpIdKey, tmpIdKey, tmpIdKey ) != 3) { |
174 | ✗ | FEL_WARNING("Failed to read tmpIdKey"); | |
175 | } | ||
176 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | idKeyEle = tmpIdKey; |
177 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | tmp = fgetc(pFile); |
178 | 11 | cpt_line = 0; | |
179 | //skip coordinates. | ||
180 |
2/2✓ Branch 0 taken 132 times.
✓ Branch 1 taken 11 times.
|
143 | while (cpt_line < 1 ) { |
181 |
1/2✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
|
132 | tmp = fgetc(pFile); |
182 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 121 times.
|
132 | if ( tmp == '\n' ) |
183 | 11 | cpt_line ++; | |
184 | } | ||
185 | 11 | felInt number_of_points = 0; | |
186 |
2/4✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
|
11 | if ( fscanf( pFile, "%d", &number_of_points ) != 1) { |
187 | ✗ | FEL_WARNING("Failed to read numPoints"); | |
188 | } | ||
189 |
5/8✓ Branch 0 taken 4 times.
✓ Branch 1 taken 7 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
|
11 | if( verbose > 0) std::cout << "numPoints : "<< number_of_points <<std::endl; |
190 |
1/2✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
|
11 | mesh.listPoints().resize( number_of_points, Point( 0. ) ); |
191 |
3/4✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 7 times.
|
11 | if(FelisceParam::instance().effective2dGEOmesh) { |
192 | 4 | mesh.numCoor() = 2; | |
193 | } else { | ||
194 | 7 | mesh.numCoor() = 3; //Always dimension 3 in format ensight6 | |
195 | } | ||
196 | |||
197 | 11 | double BBmin[3] = {Infinity, | |
198 | Infinity, | ||
199 | Infinity | ||
200 | }; | ||
201 | 11 | double BBmax[3] = {- Infinity, | |
202 | - Infinity, | ||
203 | - Infinity | ||
204 | }; | ||
205 | |||
206 | //------------------------ | ||
207 | // read the vertices | ||
208 | //! \todo treatment for ignore & off keyWord | ||
209 | int idOld; | ||
210 | 11 | std::unordered_map<int, int> oldId2OurId; | |
211 |
2/2✓ Branch 1 taken 519 times.
✓ Branch 2 taken 11 times.
|
530 | for(int iv=0; iv< mesh.numPoints(); iv++) { |
212 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 519 times.
|
519 | if ( idKeyVert == "given" ) { |
213 | ✗ | if ( fscanf( pFile, "%d", & idOld ) != 1) { | |
214 | ✗ | FEL_WARNING("Failed to read idOld"); | |
215 | } | ||
216 | ✗ | oldId2OurId[idOld] = iv+1 ; | |
217 | } | ||
218 |
1/2✓ Branch 1 taken 519 times.
✗ Branch 2 not taken.
|
519 | if ( fscanf ( pFile,"%lf%lf%lf\n", |
219 | 519 | & mesh.listPoint(iv).x(), | |
220 | 519 | & mesh.listPoint(iv).y(), | |
221 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 519 times.
|
1038 | & mesh.listPoint(iv).z() ) != 3) { |
222 | ✗ | FEL_WARNING("Failed to read listPoint"); | |
223 | } | ||
224 | 519 | mesh.listPoint(iv).x() *= spaceUnit; | |
225 | 519 | mesh.listPoint(iv).y() *= spaceUnit; | |
226 |
3/4✓ Branch 1 taken 519 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 284 times.
✓ Branch 4 taken 235 times.
|
519 | if(FelisceParam::instance().effective2dGEOmesh) { |
227 | 284 | mesh.listPoint(iv).z() = 0.; | |
228 | } else { | ||
229 | 235 | mesh.listPoint(iv).z() *= spaceUnit; | |
230 | } | ||
231 |
2/2✓ Branch 1 taken 1273 times.
✓ Branch 2 taken 519 times.
|
1792 | for (int icoor = 0; icoor < mesh.numCoor(); icoor ++) { |
232 | 1273 | BBmin[icoor] = std::min( BBmin[icoor], mesh.listPoint(iv)[icoor] ); | |
233 | 1273 | BBmax[icoor] = std::max( BBmax[icoor], mesh.listPoint(iv)[icoor] ); | |
234 | } | ||
235 | } | ||
236 | |||
237 | //------------------------ | ||
238 | // first scan of parts to do memory allocation | ||
239 | char part[5]; | ||
240 | char keyWord[10]; | ||
241 | int tmpNumEle; | ||
242 | 11 | int numPart = 0; | |
243 | int partNumber; | ||
244 | ElementType eltType; | ||
245 | int begElement [GeometricMeshRegion::m_numTypesOfElement ]; //temporary array: first element & number | ||
246 | int nbElements [GeometricMeshRegion::m_numTypesOfElement ]; // of elements for each ref by element. | ||
247 |
2/2✓ Branch 0 taken 275 times.
✓ Branch 1 taken 11 times.
|
286 | for (int iele = 0 ; iele < GeometricMeshRegion::m_numTypesOfElement; iele++) { |
248 | 275 | begElement [ iele ] = 0; | |
249 | 275 | nbElements [ iele ] = 0; | |
250 | } | ||
251 | |||
252 |
2/4✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
|
11 | if ( fscanf( pFile, "%s", part ) != 1) { |
253 | ✗ | FEL_WARNING("Failed to read part"); | |
254 | } | ||
255 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | fgetpos( pFile, & startEltPos ); |
256 |
2/2✓ Branch 1 taken 34 times.
✓ Branch 2 taken 11 times.
|
45 | while ( feof( pFile ) == 0) { |
257 | 34 | numPart ++; | |
258 |
2/4✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
|
34 | if ( fscanf( pFile, "%d", &partNumber) != 1 ) { |
259 | ✗ | FEL_WARNING("Failed to read partNumber"); | |
260 | } | ||
261 | 34 | cpt_line = 0; | |
262 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | tmp = fgetc(pFile); |
263 | //skip description line of part | ||
264 |
2/2✓ Branch 0 taken 476 times.
✓ Branch 1 taken 34 times.
|
510 | while (cpt_line < 1 ) { |
265 |
1/2✓ Branch 1 taken 476 times.
✗ Branch 2 not taken.
|
476 | tmp = fgetc(pFile); |
266 |
2/2✓ Branch 0 taken 34 times.
✓ Branch 1 taken 442 times.
|
476 | if ( tmp == '\n' ) |
267 | 34 | cpt_line ++; | |
268 | } | ||
269 |
2/4✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
|
34 | if ( fscanf( pFile, "%s", keyWord ) != 1 ) { |
270 | ✗ | FEL_WARNING("Failed to read keyWord"); | |
271 | } | ||
272 |
2/4✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
|
34 | eltType = m_eltEns6NameToEnum[keyWord]; |
273 | 34 | begElement[eltType] += nbElements[eltType] * GeometricMeshRegion::m_numPointsPerElt[eltType]; | |
274 | 34 | nbElements[eltType] = 0; | |
275 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
|
34 | if ( strcmp(keyWord,"block") == 0 ) { |
276 | //! \todo manage ERROR messages | ||
277 | ✗ | std::ostringstream msg; | |
278 | ✗ | msg << "Try to read Element type block." << std::endl; | |
279 | ✗ | FEL_ERROR(msg.str()); | |
280 | } | ||
281 | do { | ||
282 |
2/4✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
|
34 | eltType = m_eltEns6NameToEnum[keyWord]; |
283 |
1/12✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
|
34 | if( verbose > 2) std::cout<<"keyWord "<<keyWord<< " & eltType "<<eltType <<std::endl; |
284 |
2/4✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
|
34 | if ( fscanf( pFile, "%d", &tmpNumEle ) != 1 ) { |
285 | ✗ | FEL_WARNING("Failed to read tmpNumEle"); | |
286 | } | ||
287 | 34 | nbElements[eltType] += tmpNumEle; | |
288 |
2/4✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
|
34 | mesh.intRefToBegEndMaps[eltType][partNumber] = std::make_pair(begElement[eltType], nbElements[eltType]); |
289 | 34 | mesh.numElements(eltType) += tmpNumEle; | |
290 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | tmp = fgetc(pFile); |
291 | 34 | cpt_line = 0; | |
292 | //skip coordinates. | ||
293 |
2/2✓ Branch 0 taken 25357 times.
✓ Branch 1 taken 34 times.
|
25391 | while (cpt_line < tmpNumEle ) { |
294 |
1/2✓ Branch 1 taken 25357 times.
✗ Branch 2 not taken.
|
25357 | tmp = fgetc(pFile); |
295 |
2/2✓ Branch 0 taken 981 times.
✓ Branch 1 taken 24376 times.
|
25357 | if ( tmp == '\n' ) |
296 | 981 | cpt_line ++; | |
297 | } | ||
298 |
5/8✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 11 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 34 times.
|
34 | if ( fscanf( pFile, "%s", keyWord ) != 1 && feof( pFile ) == 0) { |
299 | ✗ | FEL_WARNING("Failed to read keyWord"); | |
300 | } | ||
301 |
4/6✓ Branch 0 taken 11 times.
✓ Branch 1 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
|
34 | } while ( strcmp(keyWord,part) != 0 && feof( pFile ) == 0 ); |
302 | } | ||
303 | |||
304 | ElementType eltType2; | ||
305 |
2/2✓ Branch 4 taken 275 times.
✓ Branch 5 taken 11 times.
|
286 | for(auto it_eltype = m_eltFelNameToEns6Pair.begin(); it_eltype != m_eltFelNameToEns6Pair.end(); ++it_eltype) { |
306 | 275 | eltType2 = it_eltype->second.first; | |
307 | // Allocate memory | ||
308 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 2 taken 257 times.
|
275 | if ( mesh.numElements(eltType2) != 0 ) { |
309 |
1/2✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
|
18 | mesh.allocateElements(eltType2); |
310 | } | ||
311 | } | ||
312 | |||
313 | //----------------------------- | ||
314 | // 2nd scan of file | ||
315 | // Fill the array of elements | ||
316 |
1/2✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
|
11 | std::string DescripLine=""; |
317 | char tmpDescLine[80]; | ||
318 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | fsetpos( pFile, &startEltPos ); |
319 | int nVpEl; | ||
320 | 11 | std::vector<felInt> elem; | |
321 | 11 | bool decr_vert_id = true; | |
322 | felInt start_index[ GeometricMeshRegion::m_numTypesOfElement ]; | ||
323 |
2/2✓ Branch 0 taken 275 times.
✓ Branch 1 taken 11 times.
|
286 | for (int iele = 0 ; iele < GeometricMeshRegion::m_numTypesOfElement; iele++) { |
324 | 275 | start_index [ iele ] = 0; | |
325 | } | ||
326 | 11 | GeometricMeshRegion::IntRefToElementType_type& intRefToEnum = mesh.intRefToEnum(); | |
327 | |||
328 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | m_partIdToDescLine.resize(numPart); |
329 |
2/2✓ Branch 1 taken 34 times.
✓ Branch 2 taken 11 times.
|
45 | while ( feof( pFile ) == 0) { |
330 |
2/4✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
|
34 | if ( fscanf( pFile, "%d", &partNumber ) != 1) { |
331 | ✗ | FEL_WARNING("Failed to read partNumber"); | |
332 | } | ||
333 | //scan description line | ||
334 | 34 | cpt_line = 0; | |
335 | do { | ||
336 |
2/4✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
|
34 | if ( fscanf( pFile, "%s", tmpDescLine) != 1 ) { |
337 | ✗ | FEL_WARNING("Failed to read tmpDescLine"); | |
338 | } | ||
339 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | tmp = fgetc(pFile); |
340 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | DescripLine = DescripLine + tmpDescLine; |
341 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
|
34 | } while (tmp != '\n'); |
342 |
1/2✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
|
34 | m_partIdToDescLine[ partNumber-1 ] = DescripLine; // vector begin to 0 |
343 |
2/4✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
|
34 | GeometricMeshRegion::descriptionLineEnsightToListLabel[DescripLine].insert(partNumber); |
344 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | DescripLine = ""; |
345 |
2/4✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
|
34 | if ( fscanf(pFile, "%s", keyWord ) != 1) { |
346 | ✗ | FEL_WARNING("Failed to read keyWork"); | |
347 | } | ||
348 | do { | ||
349 |
2/4✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
|
34 | if ( fscanf( pFile, "%d", & tmpNumEle ) !=1 ) { |
350 | ✗ | FEL_WARNING("Failed to read tmpNumEle"); | |
351 | } | ||
352 |
2/4✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
|
34 | eltType = m_eltEns6NameToEnum[keyWord]; |
353 |
2/4✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
|
34 | intRefToEnum[partNumber].insert( eltType ); |
354 | 34 | nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType]; | |
355 |
2/2✓ Branch 0 taken 981 times.
✓ Branch 1 taken 34 times.
|
1015 | for ( felInt iel = 0; iel < tmpNumEle; iel++) { |
356 |
1/2✓ Branch 1 taken 981 times.
✗ Branch 2 not taken.
|
981 | elem.resize(nVpEl, 0); |
357 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 981 times.
|
981 | if ( idKeyEle == "given" ) { |
358 | ✗ | if ( fscanf( pFile, "%d", & idOld ) !=1 ) { //unused idOld (id of element) | |
359 | ✗ | FEL_WARNING("Failed to read idOld"); | |
360 | } | ||
361 | } | ||
362 |
2/2✓ Branch 0 taken 3046 times.
✓ Branch 1 taken 981 times.
|
4027 | for ( int ivert = 0; ivert < nVpEl; ivert++) { |
363 |
2/4✓ Branch 1 taken 3046 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3046 times.
|
3046 | if ( fscanf( pFile, "%d", &idOld) !=1 ) { |
364 | ✗ | FEL_WARNING("Failed to read idOld"); | |
365 | } | ||
366 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3046 times.
|
3046 | if ( idKeyEle == "given" ) |
367 | ✗ | elem[ivert] = oldId2OurId[idOld]; | |
368 | else | ||
369 | 3046 | elem[ivert] = idOld; | |
370 | } | ||
371 |
1/2✓ Branch 1 taken 981 times.
✗ Branch 2 not taken.
|
981 | mesh.setOneElement(eltType, iel+start_index[ eltType ], elem, decr_vert_id); |
372 | } | ||
373 | 34 | start_index[ eltType ] += tmpNumEle; | |
374 |
5/8✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 23 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 11 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 34 times.
|
34 | if ( fscanf( pFile, "%s", keyWord ) !=1 && feof( pFile ) == 0) { |
375 | ✗ | FEL_WARNING("Failed to read keyWord"); | |
376 | } | ||
377 |
4/6✓ Branch 0 taken 11 times.
✓ Branch 1 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
|
34 | } while ( strcmp(keyWord,part) != 0 && feof( pFile ) == 0 ); |
378 | } | ||
379 | 11 | mesh.flagFormatMesh() = GeometricMeshRegion::FormatEnsight6; | |
380 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | mesh.setDomainDim(); |
381 | 11 | m_domainDim = mesh.domainDim(); | |
382 | 11 | m_createNormalTangent = mesh.createNormalTangent(); | |
383 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | mesh.setBagElementTypeDomain(); |
384 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | mesh.setBagElementTypeDomainBoundary(); |
385 | 11 | oldId2OurId.clear(); | |
386 | |||
387 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
11 | fclose(pFile); |
388 | 11 | } | |
389 | |||
390 | /***********************************************************************************/ | ||
391 | /***********************************************************************************/ | ||
392 | |||
393 | // It writes ENSIGHT6 geo file | ||
394 | 170 | void Ensight::writerGeo(GeometricMeshRegion& mesh, std::string nameOfGeoFile) | |
395 | { | ||
396 | // Getting instance | ||
397 |
1/2✓ Branch 1 taken 170 times.
✗ Branch 2 not taken.
|
170 | const auto& r_instance = FelisceParam::instance(); |
398 | |||
399 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
|
170 | if (mesh.flagFormatMesh() == GeometricMeshRegion::FormatUndefined) { |
400 | ✗ | felisce_error("Empty Data Structure!!! Have you read mesh file before?",__FILE__,__LINE__); | |
401 | } | ||
402 | |||
403 | // Initialization | ||
404 | 170 | std::string fileNameGeo, fileNameRoot, fileName; | |
405 | ElementType eltType; | ||
406 | 170 | std::string keyWord; | |
407 | int the_ref; | ||
408 | 170 | short verbose = 0; | |
409 | FILE * pFile; | ||
410 | 170 | felInt startindex = 0, numElemsPerRef = 0; | |
411 |
1/2✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
|
170 | std::vector<std::vector<felInt>> elem(1); |
412 | 170 | bool incr_vert_id = true; | |
413 |
2/2✓ Branch 1 taken 127 times.
✓ Branch 2 taken 43 times.
|
170 | if(nameOfGeoFile.empty()) { |
414 |
1/2✓ Branch 1 taken 127 times.
✗ Branch 2 not taken.
|
127 | fileNameGeo = m_outputMesh; |
415 |
1/2✓ Branch 1 taken 127 times.
✗ Branch 2 not taken.
|
127 | fileNameRoot = m_resultDir; |
416 |
1/2✓ Branch 1 taken 127 times.
✗ Branch 2 not taken.
|
127 | fileName = fileNameRoot + fileNameGeo; //where is write the geo file |
417 | } else { | ||
418 |
1/2✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
|
43 | fileName = nameOfGeoFile; |
419 | } | ||
420 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
|
170 | if (verbose > 0) { |
421 | ✗ | std::cout << "Writing file "<< fileNameGeo << std::endl; | |
422 | } | ||
423 |
1/2✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
|
170 | pFile = fopen (fileName.c_str(),"w"); |
424 |
2/2✓ Branch 0 taken 117 times.
✓ Branch 1 taken 53 times.
|
170 | if (pFile==nullptr) { |
425 |
1/2✓ Branch 1 taken 117 times.
✗ Branch 2 not taken.
|
117 | std::string command = "mkdir -p " + m_resultDir; |
426 |
1/2✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
|
117 | int ierr = system(command.c_str()); |
427 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
|
117 | if (ierr>0) { |
428 | ✗ | FEL_ERROR("Impossible to write "+fileName+" geo mesh"); | |
429 | } | ||
430 |
1/2✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
|
117 | pFile = fopen (fileName.c_str(),"w"); |
431 | 117 | } | |
432 | |||
433 | // Descriptions lines (All Geometry files must contain these first six lines) | ||
434 |
1/2✓ Branch 1 taken 170 times.
✗ Branch 2 not taken.
|
170 | fprintf(pFile,"Geometry file\n"); |
435 |
1/2✓ Branch 1 taken 170 times.
✗ Branch 2 not taken.
|
170 | fprintf(pFile,"Geometry file\n"); |
436 |
1/2✓ Branch 1 taken 170 times.
✗ Branch 2 not taken.
|
170 | fprintf(pFile,"node id assign\n"); |
437 |
1/2✓ Branch 1 taken 170 times.
✗ Branch 2 not taken.
|
170 | fprintf(pFile,"element id assign\n"); |
438 |
1/2✓ Branch 1 taken 170 times.
✗ Branch 2 not taken.
|
170 | fprintf(pFile,"coordinates\n"); |
439 |
1/2✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
|
170 | fprintf(pFile,"%8d\n",mesh.numPoints()); |
440 | |||
441 | // Write the vertices | ||
442 | 170 | const auto dimension = mesh.numCoor(); | |
443 |
2/2✓ Branch 0 taken 111 times.
✓ Branch 1 taken 59 times.
|
170 | if (dimension == 3) { |
444 |
2/2✓ Branch 1 taken 135407 times.
✓ Branch 2 taken 111 times.
|
135518 | for(int iv=0; iv< mesh.numPoints(); iv++) { |
445 |
1/2✓ Branch 3 taken 135407 times.
✗ Branch 4 not taken.
|
135407 | fprintf( pFile,"%12.5e%12.5e%12.5e\n", mesh.listPoint(iv).x(), |
446 | 135407 | mesh.listPoint(iv).y(), mesh.listPoint(iv).z() ); | |
447 | } | ||
448 |
1/2✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
|
59 | } else if (dimension == 2) { |
449 | 59 | double zcoor = 0.; | |
450 |
2/2✓ Branch 1 taken 20965 times.
✓ Branch 2 taken 59 times.
|
21024 | for(int iv=0; iv< mesh.numPoints(); iv++) { |
451 |
1/2✓ Branch 5 taken 20965 times.
✗ Branch 6 not taken.
|
20965 | fprintf( pFile, "%12.5e%12.5e%12.5e\n", mesh.listPoint(iv).x(), mesh.listPoint(iv).y(), zcoor); |
452 | } | ||
453 | } else { | ||
454 | ✗ | std::ostringstream msg; | |
455 | msg << "Error in writing geo File " << fileNameGeo << ". " | ||
456 | ✗ | << "Expecting mesh with 2 or 3 coordinates (it is " <<dimension << ")." | |
457 | ✗ | << std::endl; | |
458 | ✗ | FEL_ERROR(msg.str()); | |
459 | } | ||
460 | |||
461 | // Write the elements per references | ||
462 | 170 | int cptpart = 0; | |
463 | 170 | std::string DescriptionLine,felName; | |
464 | 170 | bool toMITC9 = false; | |
465 | 170 | auto& intRefToEnum = mesh.intRefToEnum(); | |
466 |
2/2✓ Branch 4 taken 646 times.
✓ Branch 5 taken 170 times.
|
816 | for(auto it_ref = intRefToEnum.begin(); it_ref != intRefToEnum.end(); ++it_ref) { |
467 | 646 | the_ref = (*it_ref).first; | |
468 | |||
469 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 2 taken 618 times.
|
646 | if (mesh.flagFormatMesh() == GeometricMeshRegion::FormatEnsight6) { |
470 | 28 | cptpart++; | |
471 |
1/2✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
|
28 | fprintf ( pFile, "part%8d\n",cptpart ); |
472 |
1/2✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
28 | DescriptionLine = m_partIdToDescLine[ cptpart - 1 ]; |
473 |
1/2✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
28 | fprintf (pFile, "%s", DescriptionLine.c_str() ); |
474 | } | ||
475 |
2/2✓ Branch 6 taken 724 times.
✓ Branch 7 taken 646 times.
|
1370 | for(auto it_elem = it_ref->second.begin(); it_elem != it_ref->second.end(); ++it_elem) { |
476 | 724 | eltType = *it_elem; | |
477 |
1/2✓ Branch 1 taken 724 times.
✗ Branch 2 not taken.
|
724 | numElemsPerRef = mesh.intRefToBegEndMaps[eltType][the_ref].second; |
478 | |||
479 |
2/2✓ Branch 0 taken 713 times.
✓ Branch 1 taken 11 times.
|
724 | if (numElemsPerRef > 0) { |
480 |
2/2✓ Branch 1 taken 685 times.
✓ Branch 2 taken 28 times.
|
713 | if (mesh.flagFormatMesh() == GeometricMeshRegion::FormatMedit) { |
481 | 685 | cptpart++; | |
482 |
1/2✓ Branch 1 taken 685 times.
✗ Branch 2 not taken.
|
685 | fprintf ( pFile, "part%8d\n",cptpart ); |
483 |
1/2✓ Branch 2 taken 685 times.
✗ Branch 3 not taken.
|
685 | felName = GeometricMeshRegion::eltEnumToFelNameGeoEle[eltType].first; |
484 | 685 | const auto& r_map = r_instance.felName2MapintRef2DescLine; | |
485 |
1/2✓ Branch 1 taken 685 times.
✗ Branch 2 not taken.
|
685 | auto it_felName = r_map.find(felName); |
486 |
2/2✓ Branch 2 taken 624 times.
✓ Branch 3 taken 61 times.
|
685 | if ( it_felName == r_map.end() ) { |
487 |
3/6✓ Branch 1 taken 624 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 624 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 624 times.
✗ Branch 8 not taken.
|
624 | DescriptionLine = felName + "_ref_" + std::to_string(the_ref); |
488 | } else { | ||
489 |
1/2✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
|
61 | auto it_ref2 = it_felName->second.find(the_ref); |
490 |
2/2✓ Branch 3 taken 25 times.
✓ Branch 4 taken 36 times.
|
61 | if ( it_ref2 == it_felName->second.end() ) { |
491 |
3/6✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 25 times.
✗ Branch 8 not taken.
|
25 | DescriptionLine = felName + "_ref_" + std::to_string(the_ref); |
492 | } else { | ||
493 |
1/2✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
|
36 | DescriptionLine = it_ref2->second; |
494 | } | ||
495 | } | ||
496 |
1/2✓ Branch 2 taken 685 times.
✗ Branch 3 not taken.
|
685 | fprintf (pFile, "%s", DescriptionLine.c_str() ); |
497 | } | ||
498 |
1/2✓ Branch 1 taken 713 times.
✗ Branch 2 not taken.
|
713 | fprintf(pFile,"\n"); |
499 |
1/2✓ Branch 1 taken 713 times.
✗ Branch 2 not taken.
|
713 | keyWord = getKeyword(eltType); |
500 | |||
501 | // Here the keyword is modified for quad9 | ||
502 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 713 times.
|
713 | if (eltType == 11) { //TODO: Move this to the auxiliary methods |
503 | ✗ | keyWord = "quad4"; | |
504 | ✗ | toMITC9 = true; | |
505 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 713 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
713 | } else if (eltType == 3 && toMITC9) { |
506 | ✗ | keyWord = "bar2"; | |
507 | } | ||
508 | |||
509 |
1/2✓ Branch 2 taken 713 times.
✗ Branch 3 not taken.
|
713 | fprintf( pFile, "%s", keyWord.c_str() ); |
510 |
1/2✓ Branch 1 taken 713 times.
✗ Branch 2 not taken.
|
713 | fprintf(pFile,"\n"); |
511 | |||
512 | // Num elements Q1 = 4 Q9 | ||
513 |
1/2✓ Branch 1 taken 713 times.
✗ Branch 2 not taken.
|
713 | startindex = mesh.intRefToBegEndMaps[eltType][the_ref].first; |
514 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 713 times.
|
713 | if (eltType == 11) { |
515 | ✗ | fprintf(pFile,"%8d\n", 4*numElemsPerRef); | |
516 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 713 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
713 | } else if (eltType == 3 && toMITC9) { |
517 | ✗ | fprintf(pFile,"%8d\n", 2*numElemsPerRef); | |
518 | } else { | ||
519 |
2/4✓ Branch 1 taken 713 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 713 times.
✗ Branch 5 not taken.
|
713 | fprintf(pFile,"%8d\n", getNumberOfElements(mesh, eltType, the_ref)); |
520 | } | ||
521 | |||
522 |
1/2✓ Branch 1 taken 713 times.
✗ Branch 2 not taken.
|
713 | prepareElemIndexes(elem, eltType); |
523 |
2/2✓ Branch 0 taken 608094 times.
✓ Branch 1 taken 713 times.
|
608807 | for ( felInt iel = 0; iel < numElemsPerRef; iel++) { |
524 |
1/2✓ Branch 1 taken 608094 times.
✗ Branch 2 not taken.
|
608094 | getElemIndexes(mesh, eltType, iel, elem, startindex, incr_vert_id); |
525 | |||
526 | // Here is created the news connectivities between 1 quad9 and 4 quad4 | ||
527 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 608094 times.
|
608094 | if (eltType == 11) { // Quad9 |
528 | ✗ | std::vector<felInt> listVertQ1Elem(16); | |
529 | ✗ | convertQuad9To4Quad1(listVertQ1Elem); | |
530 | ✗ | for (int k=0 ; k<4 ; k++) { | |
531 | ✗ | for ( int ivert = 0; ivert < 4; ivert++) { | |
532 | ✗ | fprintf( pFile, "%8d", elem[0][listVertQ1Elem[4*k+ivert]]); | |
533 | } | ||
534 | ✗ | fprintf(pFile,"\n"); | |
535 | } | ||
536 |
1/4✗ Branch 1 not taken.
✓ Branch 2 taken 608094 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
608094 | } else if (eltType == 3 && toMITC9) { |
537 | // bar3 (0----2----1) = 2 bar2 (0----2) (2----1) to corresponding with the quad9 = 4 quad1 | ||
538 | ✗ | fprintf( pFile, "%8d" "%8d", elem[0][0], elem[0][2] ); | |
539 | ✗ | fprintf(pFile,"\n"); | |
540 | ✗ | fprintf( pFile, "%8d" "%8d", elem[0][2], elem[0][1] ); | |
541 | ✗ | fprintf(pFile,"\n"); | |
542 | } else { | ||
543 |
2/2✓ Branch 5 taken 611807 times.
✓ Branch 6 taken 608094 times.
|
1219901 | for (auto& r_elem : elem) { |
544 |
2/2✓ Branch 1 taken 2262168 times.
✓ Branch 2 taken 611807 times.
|
2873975 | for (std::size_t ivert = 0; ivert < r_elem.size(); ivert++) { |
545 |
1/2✓ Branch 2 taken 2262168 times.
✗ Branch 3 not taken.
|
2262168 | fprintf( pFile, "%8d", r_elem[ivert]); |
546 | } | ||
547 |
1/2✓ Branch 1 taken 611807 times.
✗ Branch 2 not taken.
|
611807 | fprintf(pFile,"\n"); |
548 | } | ||
549 | } | ||
550 | } | ||
551 | } | ||
552 | } | ||
553 | } | ||
554 | |||
555 |
1/2✓ Branch 1 taken 170 times.
✗ Branch 2 not taken.
|
170 | fclose(pFile); |
556 |
2/2✓ Branch 1 taken 45 times.
✓ Branch 2 taken 125 times.
|
170 | if (mesh.createNormalTangent()){ |
557 |
1/2✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
|
45 | m_caseOutput.SetDomainDim_case(mesh.domainDim()); |
558 |
1/2✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
|
45 | m_caseOutput.SetCreateNormalTangent_case(mesh.createNormalTangent()); |
559 | 45 | std::string nameTangent; | |
560 |
2/2✓ Branch 1 taken 64 times.
✓ Branch 2 taken 45 times.
|
109 | for (int i=0 ; i<mesh.domainDim() ; i++) { |
561 |
2/4✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
|
64 | nameTangent = "tangentVector" + std::to_string(i+1); |
562 |
2/4✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 64 times.
✗ Branch 6 not taken.
|
64 | writeNormalTangent(nameTangent, mesh.listTangents(i)); |
563 | } | ||
564 |
2/4✓ Branch 3 taken 45 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 45 times.
✗ Branch 7 not taken.
|
45 | writeNormalTangent("normalVector", mesh.listNormals()); |
565 | 45 | } | |
566 | 170 | } | |
567 | |||
568 | /***********************************************************************************/ | ||
569 | /***********************************************************************************/ | ||
570 | |||
571 | //to create the news connectivities between quad9 and 4 quad1 | ||
572 | // connectivities to quad9 = { 1, 2, 3, 4, 5, 6, 7, 8, 9 } | ||
573 | // 4 quad1 with the following connectivities { 1, 5, 9, 8 } { 2, 6, 9, 5 } { 3, 7, 9, 6 } { 4, 8, 9, 7 } | ||
574 | ✗ | void Ensight::convertQuad9To4Quad1(std::vector <felInt>& listVertQ1Elem) | |
575 | { | ||
576 | ✗ | for (int i=0 ; i<4 ; i++) { | |
577 | ✗ | listVertQ1Elem[4*i] = i; | |
578 | ✗ | listVertQ1Elem[4*i+1] = 4+i; | |
579 | ✗ | listVertQ1Elem[4*i+2] = 8; | |
580 | ✗ | listVertQ1Elem[4*i+3] = 3+i; | |
581 | } | ||
582 | ✗ | listVertQ1Elem[3] = 7; | |
583 | } | ||
584 | |||
585 | /***********************************************************************************/ | ||
586 | /***********************************************************************************/ | ||
587 | |||
588 | //to get normal and tangent vectors in Ensight | ||
589 | 109 | void Ensight::writeNormalTangent(const std::string outPutFileVec, const std::vector<Point>& vect) | |
590 | { | ||
591 |
1/2✓ Branch 2 taken 109 times.
✗ Branch 3 not taken.
|
109 | std::string fileNameRoot, fileName = outPutFileVec; |
592 |
1/2✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
|
109 | fileNameRoot = m_resultDir; |
593 |
2/4✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 109 times.
✗ Branch 5 not taken.
|
109 | fileName = fileNameRoot + fileName + ".vct"; |
594 | |||
595 | FILE * pFile; | ||
596 |
1/2✓ Branch 2 taken 109 times.
✗ Branch 3 not taken.
|
109 | pFile = fopen (fileName.c_str(),"w"); |
597 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
|
109 | if (pFile==nullptr) { |
598 | ✗ | FEL_ERROR("Impossible to write "+fileName+" vectorial ensight solution"); | |
599 | } | ||
600 | |||
601 |
2/4✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 109 times.
✗ Branch 4 not taken.
|
109 | if(FelisceParam::instance().outputFileFormat == ENSIGHT6) { |
602 |
1/2✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
|
109 | fprintf( pFile, "Vector per node\n"); |
603 | 109 | int count=0; | |
604 |
2/2✓ Branch 1 taken 9332 times.
✓ Branch 2 taken 109 times.
|
9441 | for ( unsigned int i=0; i < vect.size(); i++ ) { |
605 |
1/2✓ Branch 7 taken 9332 times.
✗ Branch 8 not taken.
|
9332 | fprintf(pFile, "%12.5e%12.5e%12.5e" ,vect[i].x(), vect[i].y(), vect[i].z()); |
606 | 9332 | count=count+3; | |
607 |
2/2✓ Branch 0 taken 4657 times.
✓ Branch 1 taken 4675 times.
|
9332 | if ( count == 6 ) { |
608 |
1/2✓ Branch 1 taken 4657 times.
✗ Branch 2 not taken.
|
4657 | fprintf(pFile, "\n" ); |
609 | 4657 | count=0; | |
610 | } | ||
611 | } | ||
612 | ✗ | } else if(FelisceParam::instance().outputFileFormat == ENSIGHTGOLD) { | |
613 | ✗ | std::size_t nDim = 3; | |
614 | ✗ | int label = 0; | |
615 | ✗ | fprintf(pFile, "Ensight Gold vector per node\n"); | |
616 | |||
617 | // loop over references | ||
618 | ✗ | for (auto refIt = m_refToListOfIds.begin(); refIt != m_refToListOfIds.end(); ++refIt) { | |
619 | ✗ | label = refIt->first; | |
620 | ✗ | fprintf(pFile, "part\n"); | |
621 | ✗ | fprintf(pFile, "%10d\n", label + 1); | |
622 | ✗ | fprintf(pFile, "coordinates\n"); | |
623 | |||
624 | // [u_x_1, u_x_2, u_x_3, ..., u_y_1, u_y_2, u_y_3, ..., u_z_1, u_z_2, u_z_3, ...] | ||
625 | ✗ | for(std::size_t idim=0; idim<nDim; ++idim) | |
626 | ✗ | for(std::size_t inode=0; inode < refIt->second.size(); ++inode) | |
627 | ✗ | fprintf(pFile, "%12.5e\n", vect[refIt->second[inode]][idim]); | |
628 | } | ||
629 | ✗ | } else if(FelisceParam::instance().outputFileFormat == ENSIGHT6BIN) { | |
630 | char buffer[80]; | ||
631 | ✗ | local_strncpy(buffer, "Vector per node\n",80); | |
632 | ✗ | fwrite(buffer, sizeof(char), 80, pFile); | |
633 | ✗ | std::vector<float> array(3*vect.size()); | |
634 | ✗ | for(std::size_t i=0 ; i< vect.size() ; i++) { | |
635 | ✗ | for (std::size_t j=0 ; j<3 ; j++) | |
636 | ✗ | array[3*i+j] = static_cast<float>(vect[i].coor(j)); | |
637 | } | ||
638 | ✗ | fwrite(array.data(),sizeof(float),3*vect.size(),pFile); | |
639 | } | ||
640 | |||
641 | else { | ||
642 | ✗ | FEL_ERROR("Unknown output file format"); | |
643 | } | ||
644 | |||
645 |
1/2✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
|
109 | fclose( pFile ); |
646 | 109 | } | |
647 | |||
648 | /***********************************************************************************/ | ||
649 | /***********************************************************************************/ | ||
650 | |||
651 | // It writes ENSIGHT GOLD geo file | ||
652 | //! \todo manage verbose | ||
653 | ✗ | void Ensight::writerGeoGold(GeometricMeshRegion& mesh, std::string nameOfGeoFile) | |
654 | { | ||
655 | ✗ | m_caseOutput.SetDomainDim_case(mesh.domainDim()); | |
656 | ✗ | m_caseOutput.SetCreateNormalTangent_case(mesh.createNormalTangent()); | |
657 | |||
658 | ✗ | if (mesh.flagFormatMesh() == GeometricMeshRegion::FormatUndefined) { | |
659 | ✗ | felisce_error("Empty Data Structure!!! Have you read mesh file before?",__FILE__,__LINE__); | |
660 | } | ||
661 | |||
662 | // clear std::unordered_map | ||
663 | ✗ | m_refToListOfIds.clear(); | |
664 | |||
665 | // Initialization | ||
666 | // ============= | ||
667 | ✗ | std::string fileNameGeo, fileNameRoot, fileName; | |
668 | ✗ | std::string keyWord; | |
669 | FILE * pFile; | ||
670 | |||
671 | ✗ | if(nameOfGeoFile.empty()) { | |
672 | ✗ | fileNameGeo = m_outputMesh; | |
673 | ✗ | fileNameRoot = m_resultDir; | |
674 | ✗ | fileName = fileNameRoot + fileNameGeo; //where is write the geo file | |
675 | } else { | ||
676 | ✗ | fileName = nameOfGeoFile; | |
677 | } | ||
678 | |||
679 | ✗ | pFile = fopen (fileName.c_str(),"w"); | |
680 | ✗ | if (pFile==nullptr) { | |
681 | ✗ | std::string command = "mkdir -p " + m_resultDir; | |
682 | ✗ | int ierr = system(command.c_str()); | |
683 | ✗ | if (ierr>0) { | |
684 | ✗ | FEL_ERROR("Impossible to write "+fileName+" geo mesh"); | |
685 | } | ||
686 | ✗ | pFile = fopen (fileName.c_str(),"w"); | |
687 | } | ||
688 | |||
689 | // Descriptions lines (All Geometry files must contain these first six lines) | ||
690 | ✗ | fprintf(pFile,"Geometry file\n"); | |
691 | ✗ | fprintf(pFile,"Geometry file\n"); | |
692 | ✗ | fprintf(pFile,"node id given\n"); | |
693 | ✗ | fprintf(pFile,"element id assign\n"); | |
694 | |||
695 | // list of type of element by labels | ||
696 | ✗ | GeometricMeshRegion::IntRefToElementType_type& intRefToEnum = mesh.intRefToEnum(); | |
697 | |||
698 | felInt label; | ||
699 | ✗ | bool(*comparison)(std::pair<felInt, Point >, std::pair<felInt, Point >) = Tools::pairComparison; | |
700 | |||
701 | // loop over references | ||
702 | ✗ | for (auto refIt = intRefToEnum.begin(); refIt != intRefToEnum.end(); ++refIt) { | |
703 | ✗ | label = refIt->first; | |
704 | ✗ | fprintf(pFile, "part\n"); | |
705 | ✗ | fprintf(pFile, "%10d\n", label + 1); | |
706 | |||
707 | ✗ | std::string descriptionLine = ""; | |
708 | ✗ | for (auto typeIt = refIt->second.begin(); typeIt != refIt->second.end(); ++typeIt) | |
709 | ✗ | descriptionLine += GeometricMeshRegion::eltEnumToFelNameGeoEle[*typeIt].first + "_"; | |
710 | |||
711 | ✗ | descriptionLine += "ref_"; | |
712 | ✗ | fprintf(pFile, "%s%d\n", descriptionLine.c_str(), label); | |
713 | ✗ | fprintf(pFile, "coordinates\n"); | |
714 | |||
715 | ✗ | std::vector<felInt> numElementOfType(GeometricMeshRegion::m_numTypesOfElement, 0); | |
716 | ✗ | std::map<felInt, felInt> local2GlobalMapping; | |
717 | ✗ | std::set<std::pair<felInt, Point >, bool(*)(std::pair<felInt, Point >, std::pair<felInt, Point >)> listOfNodes(comparison); | |
718 | |||
719 | // loop over the type of element having this reference | ||
720 | ✗ | for (auto typeIt = refIt->second.begin(); typeIt != refIt->second.end(); ++typeIt) { | |
721 | // fill the mappings | ||
722 | ✗ | felInt numPointPerElt = mesh.numPtsPerElement(*typeIt); | |
723 | ✗ | auto it_ref = mesh.intRefToBegEndMaps[*typeIt].find(label); | |
724 | ✗ | felInt startindex = it_ref->second.first; | |
725 | ✗ | felInt numElt = it_ref->second.second; | |
726 | |||
727 | felInt idPoint; | ||
728 | Point pt; | ||
729 | |||
730 | ✗ | for (felInt iel = 0 ; iel < numElt; iel++) { | |
731 | ✗ | for (int jvert = 0; jvert < numPointPerElt; jvert++) { | |
732 | ✗ | idPoint = mesh.listElements(*typeIt)[startindex + iel*numPointPerElt + jvert]; | |
733 | ✗ | pt = mesh.listPoint(idPoint); | |
734 | ✗ | listOfNodes.insert(std::make_pair(idPoint, pt)); | |
735 | } | ||
736 | } | ||
737 | |||
738 | ✗ | numElementOfType[*typeIt] = numElt; | |
739 | } | ||
740 | |||
741 | ✗ | fprintf(pFile, "%10d\n", static_cast<int>(listOfNodes.size())); | |
742 | ✗ | felInt localCounter = 1; | |
743 | ✗ | for (auto nodeIt = listOfNodes.begin(); nodeIt != listOfNodes.end(); ++nodeIt) { | |
744 | ✗ | m_refToListOfIds[label].push_back(nodeIt->first); | |
745 | |||
746 | ✗ | fprintf(pFile, "%10d\n", nodeIt->first + 1); | |
747 | ✗ | local2GlobalMapping[nodeIt->first] = localCounter; | |
748 | ✗ | ++localCounter; | |
749 | } | ||
750 | |||
751 | ✗ | for(felInt icoor=0; icoor<3; ++icoor) { | |
752 | ✗ | for (auto nodeIt = listOfNodes.begin(); nodeIt != listOfNodes.end(); ++nodeIt) { | |
753 | ✗ | fprintf(pFile, "%12.5e\n", nodeIt->second[icoor]); | |
754 | } | ||
755 | } | ||
756 | |||
757 | ✗ | for (auto typeIt = refIt->second.begin(); typeIt != refIt->second.end(); ++typeIt) { | |
758 | ✗ | keyWord = m_eltFelNameToEns6Pair[GeometricMeshRegion::eltEnumToFelNameGeoEle[*typeIt].first].second; | |
759 | ✗ | fprintf(pFile, "%s\n", keyWord.c_str()); | |
760 | ✗ | fprintf(pFile, "%10d\n", numElementOfType[*typeIt]); | |
761 | |||
762 | ✗ | felInt numPointPerElt = mesh.numPtsPerElement(*typeIt); | |
763 | ✗ | auto it_ref = mesh.intRefToBegEndMaps[*typeIt].find(label); | |
764 | ✗ | felInt startindex = it_ref->second.first; | |
765 | ✗ | felInt numElt = it_ref->second.second; | |
766 | |||
767 | ✗ | for (felInt iel = 0 ; iel < numElt; iel++) { | |
768 | ✗ | for (int jvert = 0; jvert < numPointPerElt; jvert++) { | |
769 | ✗ | fprintf(pFile, "%10d", local2GlobalMapping[mesh.listElements(*typeIt)[startindex + iel*numPointPerElt + jvert]]); | |
770 | } | ||
771 | ✗ | fprintf(pFile, "\n"); | |
772 | } | ||
773 | } | ||
774 | } | ||
775 | |||
776 | ✗ | fclose(pFile); | |
777 | |||
778 | ✗ | if (mesh.createNormalTangent()){ | |
779 | ✗ | std::string nameTangent; | |
780 | ✗ | for (int i=0 ; i<mesh.domainDim() ; i++) { | |
781 | ✗ | nameTangent = "tangentVector" + std::to_string(i+1); | |
782 | ✗ | writeNormalTangent(nameTangent, mesh.listTangents(i)); | |
783 | } | ||
784 | ✗ | writeNormalTangent("normalVector", mesh.listNormals()); | |
785 | } | ||
786 | } | ||
787 | |||
788 | /***********************************************************************************/ | ||
789 | /***********************************************************************************/ | ||
790 | |||
791 | // It writes ENSIGHT6 geo file of rank-th | ||
792 | ✗ | void Ensight::writerGeo(GeometricMeshRegion& mesh,int rank) | |
793 | { | ||
794 | ✗ | if (mesh.flagFormatMesh() == GeometricMeshRegion::FormatUndefined) { | |
795 | ✗ | felisce_error("Empty Data Structure!!! Have you read mesh file before?",__FILE__,__LINE__); | |
796 | } | ||
797 | // Initialization | ||
798 | // ============= | ||
799 | ✗ | std::string fileNameGeo, fileNameRoot, fileName; | |
800 | ✗ | ElementType eltType = static_cast<ElementType>(0); | |
801 | ✗ | std::string keyWord; | |
802 | int the_ref; | ||
803 | ✗ | short verbose = 1; | |
804 | FILE * pFile; | ||
805 | ✗ | felInt startindex = 0, numElemsPerRef = 0; | |
806 | ✗ | std::vector<std::vector<felInt>> elem(1); | |
807 | ✗ | bool incr_vert_id = true; | |
808 | ✗ | fileNameGeo = m_outputMesh; | |
809 | ✗ | fileNameRoot = m_resultDir; | |
810 | ✗ | const std::string rankName = rank == -1 ? "" : std::to_string( rank ); | |
811 | ✗ | fileName = fileNameRoot + rankName + fileNameGeo; | |
812 | ✗ | if (verbose>0) std::cout << "Writing file "<< fileNameGeo << std::endl; | |
813 | |||
814 | ✗ | pFile = fopen (fileName.c_str(),"w"); | |
815 | ✗ | if (pFile==nullptr) { | |
816 | ✗ | std::string command = "mkdir -p " + m_resultDir; | |
817 | ✗ | int ierr = system(command.c_str()); | |
818 | ✗ | if (ierr>0) | |
819 | ✗ | FEL_ERROR("Impossible to write "+fileName+" geo mesh"); | |
820 | ✗ | pFile = fopen (fileName.c_str(),"w"); | |
821 | } | ||
822 | // Descriptions lines (All Geometry files must contain these first six lines) | ||
823 | ✗ | fprintf(pFile,"Geometry file\n"); | |
824 | ✗ | fprintf(pFile,"Geometry file\n"); | |
825 | ✗ | fprintf(pFile,"node id assign\n"); | |
826 | ✗ | fprintf(pFile,"element id assign\n"); | |
827 | ✗ | fprintf(pFile,"coordinates\n"); | |
828 | ✗ | fprintf(pFile,"%8d\n",mesh.numPoints()); | |
829 | |||
830 | // Write the vertices | ||
831 | ✗ | if ( mesh.numCoor() == 3 ) { | |
832 | ✗ | for(int iv=0; iv< mesh.numPoints(); iv++) { | |
833 | ✗ | fprintf( pFile,"%12.5e%12.5e%12.5e\n", mesh.listPoint(iv).x(), | |
834 | ✗ | mesh.listPoint(iv).y(), mesh.listPoint(iv).z() ); | |
835 | } | ||
836 | ✗ | } else if ( mesh.numCoor() == 2 ) { | |
837 | ✗ | double zcoor = 0.; | |
838 | ✗ | for(int iv=0; iv< mesh.numPoints(); iv++) { | |
839 | ✗ | fprintf( pFile, "%12.5e%12.5e%12.5e\n", mesh.listPoint(iv).x(), mesh.listPoint(iv).y(), zcoor); | |
840 | } | ||
841 | } else { | ||
842 | //! manage errors | ||
843 | ✗ | std::ostringstream msg; | |
844 | msg << "Error in writing geo File " << fileNameGeo << ". " | ||
845 | ✗ | << "Expecting mesh with 2 or 3 coordinates (it is " << mesh.numCoor() << ")." | |
846 | ✗ | << std::endl; | |
847 | ✗ | FEL_ERROR(msg.str()); | |
848 | } | ||
849 | |||
850 | // Write the elements per references. | ||
851 | //------------ | ||
852 | ✗ | int cptpart = 0; | |
853 | ✗ | std::string DescriptionLine,felName; | |
854 | ✗ | GeometricMeshRegion::IntRefToElementType_type& intRefToEnum = mesh.intRefToEnum(); | |
855 | ✗ | for(auto it_ref = intRefToEnum.begin(); it_ref != intRefToEnum.end(); ++it_ref) { | |
856 | ✗ | the_ref = it_ref->first; | |
857 | ✗ | numElemsPerRef = mesh.intRefToBegEndMaps[eltType][the_ref].second; | |
858 | ✗ | if (numElemsPerRef > 0) { | |
859 | ✗ | if (mesh.flagFormatMesh() == GeometricMeshRegion::FormatEnsight6) { | |
860 | ✗ | cptpart++; | |
861 | ✗ | fprintf ( pFile, "part%8d\n",cptpart ); | |
862 | ✗ | DescriptionLine = m_partIdToDescLine[ cptpart - 1 ]; | |
863 | ✗ | fprintf (pFile, "%s", DescriptionLine.c_str() ); | |
864 | } | ||
865 | ✗ | for(auto it_elem = it_ref->second.begin(); it_elem != it_ref->second.end(); ++it_elem) { | |
866 | ✗ | eltType = *it_elem; | |
867 | ✗ | if (mesh.flagFormatMesh() == GeometricMeshRegion::FormatMedit) { | |
868 | ✗ | cptpart++; | |
869 | ✗ | fprintf ( pFile, "part%8d\n",cptpart ); | |
870 | ✗ | felName = GeometricMeshRegion::eltEnumToFelNameGeoEle[eltType].first; | |
871 | ✗ | auto it_felName = FelisceParam::instance().felName2MapintRef2DescLine.find(felName); | |
872 | ✗ | if ( it_felName == FelisceParam::instance().felName2MapintRef2DescLine.end() ) { | |
873 | ✗ | DescriptionLine = felName + "_ref_" + std::to_string(the_ref); | |
874 | } else { | ||
875 | ✗ | auto it_ref2 = it_felName->second.find(the_ref); | |
876 | ✗ | if ( it_ref2 == it_felName->second.end() ) { | |
877 | ✗ | DescriptionLine = felName + "_ref_" + std::to_string(the_ref); | |
878 | } else { | ||
879 | ✗ | DescriptionLine = it_ref2->second; | |
880 | } | ||
881 | } | ||
882 | ✗ | fprintf (pFile, "%s", DescriptionLine.c_str() ); | |
883 | } | ||
884 | ✗ | fprintf(pFile,"\n"); | |
885 | ✗ | keyWord = getKeyword(eltType); | |
886 | ✗ | fprintf( pFile, "%s", keyWord.c_str() ); | |
887 | ✗ | fprintf(pFile,"\n"); | |
888 | ✗ | startindex = mesh.intRefToBegEndMaps[eltType][the_ref].first; | |
889 | ✗ | fprintf(pFile,"%8d\n", getNumberOfElements(mesh, eltType, the_ref)); | |
890 | ✗ | prepareElemIndexes(elem, eltType); | |
891 | ✗ | for ( felInt iel = 0; iel < numElemsPerRef; iel++) { | |
892 | ✗ | getElemIndexes(mesh, eltType, iel, elem, startindex, incr_vert_id); | |
893 | ✗ | for (auto& r_elem : elem) { | |
894 | ✗ | for (std::size_t ivert = 0; ivert < r_elem.size(); ivert++) { | |
895 | ✗ | fprintf( pFile, "%8d", r_elem[ivert]); | |
896 | } | ||
897 | ✗ | fprintf(pFile,"\n"); | |
898 | } | ||
899 | } | ||
900 | } | ||
901 | } | ||
902 | } | ||
903 | ✗ | fclose(pFile); | |
904 | } | ||
905 | |||
906 | /***********************************************************************************/ | ||
907 | /***********************************************************************************/ | ||
908 | |||
909 | ✗ | void Ensight::writerGeoBin(GeometricMeshRegion& mesh, std::string nameOfGeoFile) | |
910 | { | ||
911 | ✗ | if (mesh.flagFormatMesh() == GeometricMeshRegion::FormatUndefined) { | |
912 | ✗ | felisce_error("Empty Data Structure!!! Have you read mesh file before?",__FILE__,__LINE__); | |
913 | } | ||
914 | ✗ | short verbose = 2; | |
915 | // Initialization | ||
916 | // ============= | ||
917 | ✗ | std::string fileNameGeo, fileNameRoot, fileName; | |
918 | FILE *pFile; | ||
919 | ✗ | if(nameOfGeoFile.empty()) { | |
920 | ✗ | fileNameGeo = m_outputMesh; | |
921 | ✗ | fileNameRoot = m_resultDir; | |
922 | ✗ | fileName = fileNameRoot + fileNameGeo; //where is write the geo file | |
923 | } else { | ||
924 | ✗ | fileName = nameOfGeoFile; | |
925 | } | ||
926 | ✗ | if (verbose>0) std::cout << "Writing binary file "<< fileNameGeo << std::endl; | |
927 | ✗ | pFile = fopen (fileName.c_str(),"wb"); | |
928 | ✗ | if (pFile==nullptr) { | |
929 | ✗ | std::string command = "mkdir -p " + m_resultDir; | |
930 | ✗ | int ierr = system(command.c_str()); | |
931 | ✗ | if (ierr>0) | |
932 | ✗ | FEL_ERROR("Impossible to write "+fileName+" binary geo mesh"); | |
933 | ✗ | pFile = fopen (fileName.c_str(),"w"); | |
934 | } | ||
935 | |||
936 | char buffer[80]; | ||
937 | ✗ | local_strncpy(buffer,"C Binary",80); | |
938 | ✗ | fwrite(buffer, sizeof(char), 80, pFile); | |
939 | ✗ | local_strncpy(buffer, "Description line 1",80); | |
940 | ✗ | fwrite(buffer, sizeof(char), 80, pFile); | |
941 | ✗ | local_strncpy(buffer, "Description line 2",80); | |
942 | ✗ | fwrite(buffer, sizeof(char), 80, pFile); | |
943 | ✗ | local_strncpy(buffer, "node id assign",80); | |
944 | ✗ | fwrite(buffer, sizeof(char), 80, pFile); | |
945 | ✗ | local_strncpy(buffer, "element id assign",80); | |
946 | ✗ | fwrite(buffer, sizeof(char), 80, pFile); | |
947 | ✗ | local_strncpy(buffer, "coordinates",80); | |
948 | ✗ | fwrite(buffer, sizeof(char), 80, pFile); | |
949 | ✗ | felInt number_of_points = mesh.numPoints(); | |
950 | ✗ | fwrite(&number_of_points, sizeof(int), 1, pFile); | |
951 | ✗ | std::vector<float> coordinates(3*number_of_points); | |
952 | ✗ | for(felInt iv=0; iv< number_of_points; iv++) { | |
953 | ✗ | coordinates[iv*3] = static_cast<float>(mesh.listPoint(iv).x()); | |
954 | ✗ | coordinates[iv*3 + 1] = static_cast<float>(mesh.listPoint(iv).y()); | |
955 | ✗ | coordinates[iv*3 + 2] = static_cast<float>(mesh.listPoint(iv).z()); | |
956 | } | ||
957 | ✗ | fwrite(coordinates.data(), sizeof(float), 3*number_of_points, pFile); | |
958 | |||
959 | ✗ | int cptpart = 0; | |
960 | ElementType eltType; | ||
961 | int the_ref; | ||
962 | ✗ | std::string part; | |
963 | ✗ | std::string DescriptionLine, felName; | |
964 | ✗ | std::string keyWord; | |
965 | ✗ | int nVpEl = 0; | |
966 | ✗ | felInt startindex = 0, numElemsPerRef = 0; | |
967 | ✗ | std::vector<int> tabElem; | |
968 | ✗ | std::vector<felInt> elem; | |
969 | ✗ | bool incr_vert_id = true; | |
970 | ✗ | GeometricMeshRegion::IntRefToElementType_type& intRefToEnum = mesh.intRefToEnum(); | |
971 | ✗ | for(auto it_ref = intRefToEnum.begin(); it_ref != intRefToEnum.end(); ++it_ref) { | |
972 | |||
973 | ✗ | the_ref = (*it_ref).first; | |
974 | ✗ | if (mesh.flagFormatMesh() == GeometricMeshRegion::FormatEnsight6) { | |
975 | ✗ | cptpart++; | |
976 | ✗ | part = "part " + std::to_string(cptpart); | |
977 | ✗ | local_strncpy(buffer, part.c_str(),80); | |
978 | ✗ | fwrite(buffer, sizeof(char), 80, pFile); | |
979 | ✗ | DescriptionLine = m_partIdToDescLine[ cptpart - 1 ]; | |
980 | ✗ | local_strncpy(buffer, DescriptionLine.c_str(),80); | |
981 | ✗ | fwrite(buffer, sizeof(char), 80, pFile); | |
982 | } | ||
983 | ✗ | for(auto it_elem = it_ref->second.begin(); it_elem != it_ref->second.end(); ++it_elem) { | |
984 | ✗ | eltType = *it_elem; | |
985 | ✗ | if (mesh.flagFormatMesh() == GeometricMeshRegion::FormatMedit) { | |
986 | ✗ | cptpart++; | |
987 | ✗ | part = "part " + std::to_string(cptpart); | |
988 | ✗ | local_strncpy(buffer, part.c_str(),80); | |
989 | ✗ | fwrite(buffer, sizeof(char), 80, pFile); | |
990 | ✗ | felName = GeometricMeshRegion::eltEnumToFelNameGeoEle[eltType].first; | |
991 | ✗ | auto it_felName = FelisceParam::instance().felName2MapintRef2DescLine.find(felName); | |
992 | ✗ | if ( it_felName == FelisceParam::instance().felName2MapintRef2DescLine.end() ) { | |
993 | ✗ | DescriptionLine = felName + "_ref_" + std::to_string(the_ref); | |
994 | } else { | ||
995 | ✗ | auto it_ref2 = it_felName->second.find(the_ref); | |
996 | ✗ | if ( it_ref2 == it_felName->second.end() ) { | |
997 | ✗ | DescriptionLine = felName + "_ref_" + std::to_string(the_ref); | |
998 | } else { | ||
999 | ✗ | DescriptionLine = it_ref2->second; | |
1000 | } | ||
1001 | } | ||
1002 | ✗ | local_strncpy(buffer, DescriptionLine.c_str(),80); | |
1003 | ✗ | fwrite(buffer, sizeof(char), 80, pFile); | |
1004 | } | ||
1005 | ✗ | keyWord = m_eltFelNameToEns6Pair[ GeometricMeshRegion::eltEnumToFelNameGeoEle[eltType].first ].second; | |
1006 | ✗ | local_strncpy(buffer, keyWord.c_str(),80); | |
1007 | ✗ | fwrite(buffer, sizeof(char), 80, pFile); | |
1008 | ✗ | numElemsPerRef = mesh.intRefToBegEndMaps[eltType][the_ref].second; | |
1009 | ✗ | startindex = mesh.intRefToBegEndMaps[eltType][the_ref].first; | |
1010 | ✗ | fwrite(&numElemsPerRef, sizeof(int), 1, pFile); | |
1011 | ✗ | nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType]; | |
1012 | ✗ | tabElem.resize(nVpEl*numElemsPerRef); | |
1013 | ✗ | for ( felInt iel = 0; iel < numElemsPerRef; iel++) { | |
1014 | ✗ | elem.resize(nVpEl, 0); | |
1015 | ✗ | mesh.getOneElement(eltType, iel, elem, startindex, incr_vert_id); | |
1016 | ✗ | for (int ivert = 0; ivert < nVpEl; ivert++) { | |
1017 | ✗ | tabElem[iel*nVpEl + ivert] = elem[ivert]; | |
1018 | } | ||
1019 | } | ||
1020 | ✗ | fwrite(tabElem.data(), sizeof(int), nVpEl*numElemsPerRef, pFile); | |
1021 | } | ||
1022 | } | ||
1023 | ✗ | fclose(pFile); | |
1024 | ✗ | if (mesh.createNormalTangent()){ | |
1025 | ✗ | m_caseOutput.SetDomainDim_case(mesh.domainDim()); | |
1026 | ✗ | m_caseOutput.SetCreateNormalTangent_case(mesh.createNormalTangent()); | |
1027 | ✗ | std::string nameTangent; | |
1028 | ✗ | for (int i=0 ; i<mesh.domainDim() ; i++) { | |
1029 | ✗ | nameTangent = "tangentVector" + std::to_string(i+1); | |
1030 | ✗ | writeNormalTangent(nameTangent, mesh.listTangents(i)); | |
1031 | } | ||
1032 | ✗ | writeNormalTangent("normalVector", mesh.listNormals()); | |
1033 | } | ||
1034 | } | ||
1035 | |||
1036 | /***********************************************************************************/ | ||
1037 | /***********************************************************************************/ | ||
1038 | |||
1039 | 3112 | void Ensight::postProcess(const std::string& outputDirectory, | |
1040 | const std::string& nameCase, | ||
1041 | int optionMultiCase, | ||
1042 | double& time) | ||
1043 | { | ||
1044 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3112 times.
|
3112 | if(FelisceParam::instance().outputFileFormat == ENSIGHTGOLD) { |
1045 | ✗ | for(std::size_t i=0; i<m_caseOutput.numVariables(); ++i) { | |
1046 | ✗ | m_caseOutput.variable(i).setRefToListOfIds(m_refToListOfIds); | |
1047 | } | ||
1048 | } | ||
1049 | // m_caseOutput.domainDim() = m_domainDim; | ||
1050 | 3112 | m_caseOutput.postProcess(outputDirectory,nameCase,optionMultiCase,time); | |
1051 | 3112 | } | |
1052 | |||
1053 | /***********************************************************************************/ | ||
1054 | /***********************************************************************************/ | ||
1055 | |||
1056 | 468 | void Ensight::readCaseFile() | |
1057 | { | ||
1058 | 468 | m_caseInput.read(m_inputDirectory, m_inputFile); | |
1059 | 468 | } | |
1060 | |||
1061 | /***********************************************************************************/ | ||
1062 | /***********************************************************************************/ | ||
1063 | |||
1064 | 24 | void Ensight::readVariable(int idVariable, double time, double* valueOfVariable, felInt size) | |
1065 | { | ||
1066 | 24 | int indexTime = m_caseInput.timeIndex(time); | |
1067 | 24 | m_caseInput.readVariable(idVariable, indexTime, valueOfVariable, size); | |
1068 | 24 | } | |
1069 | |||
1070 | /***********************************************************************************/ | ||
1071 | /***********************************************************************************/ | ||
1072 | |||
1073 | 5378 | void Ensight::addVariable(int typeVariable, const std::string nameVariable, | |
1074 | const double* solution, const felInt size, bool manageMemory) | ||
1075 | { | ||
1076 |
1/2✓ Branch 1 taken 5378 times.
✗ Branch 2 not taken.
|
5378 | m_caseOutput.addVariable(static_cast<EnsightVariable::TypeVar>(typeVariable), nameVariable, solution, size, manageMemory); |
1077 | 5378 | } | |
1078 | |||
1079 | /***********************************************************************************/ | ||
1080 | /***********************************************************************************/ | ||
1081 | |||
1082 | 2154 | EnsightCase::EnsightCase(): | |
1083 | 2154 | m_verbose(0), | |
1084 | 2154 | m_domainDim(0), | |
1085 | 2154 | m_createNormalTangent(false), | |
1086 |
1/2✓ Branch 2 taken 2154 times.
✗ Branch 3 not taken.
|
2154 | m_directory("none"), |
1087 |
1/2✓ Branch 2 taken 2154 times.
✗ Branch 3 not taken.
|
2154 | m_filename("none"), |
1088 | 2154 | m_sectionFormat(0), | |
1089 | 2154 | m_sectionGeometry(0), | |
1090 | 2154 | m_sectionVariable(0), | |
1091 | 2154 | m_sectionTime(0), | |
1092 | 2154 | m_model_time_set(0), | |
1093 | 2154 | m_model_file_set(0), | |
1094 | 2154 | m_change_coords_only(false), | |
1095 | 2154 | m_change_coords_only_cstep(false), | |
1096 |
1/2✓ Branch 2 taken 2154 times.
✗ Branch 3 not taken.
|
2154 | m_geo_file("none"), |
1097 |
1/2✓ Branch 2 taken 2154 times.
✗ Branch 3 not taken.
|
2154 | m_geo_file_wildcard("none"), |
1098 | 2154 | m_num_wildcard(0), | |
1099 | 4308 | m_num_variable(0) | |
1100 | { | ||
1101 | |||
1102 | 2154 | } | |
1103 | |||
1104 | /***********************************************************************************/ | ||
1105 | /***********************************************************************************/ | ||
1106 | |||
1107 | ✗ | EnsightCase::EnsightCase(int verbose):m_verbose(verbose) | |
1108 | {} | ||
1109 | |||
1110 | /***********************************************************************************/ | ||
1111 | /***********************************************************************************/ | ||
1112 | |||
1113 | 995 | void EnsightCase::initialize(const std::string& nameGeoFile,int time_set, | |
1114 | int num_steps,int filename_start_number, | ||
1115 | int filename_increment ) | ||
1116 | { | ||
1117 |
1/2✓ Branch 1 taken 995 times.
✗ Branch 2 not taken.
|
995 | m_geo_file = nameGeoFile; |
1118 | 995 | m_var.clear(); | |
1119 | 995 | m_time.clear(); | |
1120 |
1/2✓ Branch 1 taken 995 times.
✗ Branch 2 not taken.
|
995 | EnsightTimeBis time(time_set,num_steps,filename_start_number,filename_increment); |
1121 |
1/2✓ Branch 1 taken 995 times.
✗ Branch 2 not taken.
|
995 | m_time.push_back(time); |
1122 | 995 | } | |
1123 | |||
1124 | /***********************************************************************************/ | ||
1125 | /***********************************************************************************/ | ||
1126 | |||
1127 | ✗ | EnsightVariable const& EnsightCase::variable(int ivar) const | |
1128 | { | ||
1129 | ✗ | return m_var[ivar]; | |
1130 | } | ||
1131 | |||
1132 | /***********************************************************************************/ | ||
1133 | /***********************************************************************************/ | ||
1134 | |||
1135 | ✗ | EnsightVariable& EnsightCase::variable(int ivar) | |
1136 | { | ||
1137 | ✗ | return m_var[ivar]; | |
1138 | } | ||
1139 | |||
1140 | /***********************************************************************************/ | ||
1141 | /***********************************************************************************/ | ||
1142 | |||
1143 | ✗ | EnsightTimeBis& EnsightCase::timeSet(int iset) | |
1144 | { | ||
1145 | ✗ | return m_time[iset]; | |
1146 | } | ||
1147 | |||
1148 | /***********************************************************************************/ | ||
1149 | /***********************************************************************************/ | ||
1150 | |||
1151 | 468 | void EnsightCase::read(const std::string& directory,const std::string& case_file) | |
1152 | { | ||
1153 | 468 | m_sectionFormat=-1; | |
1154 | 468 | m_sectionGeometry=-1; | |
1155 | 468 | m_sectionVariable=-1; | |
1156 | 468 | m_sectionTime=-1; | |
1157 |
1/2✓ Branch 1 taken 468 times.
✗ Branch 2 not taken.
|
468 | m_line.resize(0); |
1158 |
1/2✓ Branch 1 taken 468 times.
✗ Branch 2 not taken.
|
468 | m_directory = directory; |
1159 |
1/2✓ Branch 1 taken 468 times.
✗ Branch 2 not taken.
|
468 | m_filename = case_file; |
1160 |
2/4✓ Branch 1 taken 468 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 468 times.
✗ Branch 5 not taken.
|
468 | const std::string casefilename = m_directory+"/"+case_file; |
1161 |
1/2✓ Branch 2 taken 468 times.
✗ Branch 3 not taken.
|
468 | std::ifstream casefile(casefilename.c_str(), std::ios_base::in); |
1162 |
1/8✗ Branch 0 not taken.
✓ Branch 1 taken 468 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
|
468 | if(m_verbose) std::cout << "EnsightCase::read case file " << casefilename << std::endl; |
1163 |
3/4✓ Branch 1 taken 468 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 460 times.
✓ Branch 4 taken 8 times.
|
468 | if( !casefile) { |
1164 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 460 times.
|
460 | if (m_verbose) |
1165 | ✗ | std::cout << "Cannot open " << casefilename << std::endl; | |
1166 | } else { | ||
1167 | std::size_t found; | ||
1168 | 8 | std::string dummy; | |
1169 | 8 | int i=0; | |
1170 |
4/6✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 112 times.
✓ Branch 7 taken 8 times.
|
120 | while ( getline( casefile, dummy ) ) { |
1171 |
1/2✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
|
112 | m_line.push_back(dummy); |
1172 | 112 | found=m_line[i].find("FORMAT"); | |
1173 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 104 times.
|
112 | if(found!=std::string::npos) m_sectionFormat=i; |
1174 | 112 | found=m_line[i].find("GEOMETRY"); | |
1175 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 104 times.
|
112 | if(found!=std::string::npos) m_sectionGeometry=i; |
1176 | 112 | found=m_line[i].find("VARIABLE"); | |
1177 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 104 times.
|
112 | if(found!=std::string::npos) m_sectionVariable=i; |
1178 | 112 | found=m_line[i].find("TIME"); | |
1179 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 104 times.
|
112 | if(found!=std::string::npos) m_sectionTime=i; |
1180 | 112 | i++; | |
1181 | } | ||
1182 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | casefile.close(); |
1183 | |||
1184 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8 | if(m_sectionFormat==-1) { |
1185 | ✗ | FEL_ERROR("Error reading ensight case file: FORMAT section is required") | |
1186 | } | ||
1187 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8 | if(m_sectionGeometry==-1) { |
1188 | ✗ | FEL_ERROR("Error reading ensight case file: GEOMETRY section is required") | |
1189 | } | ||
1190 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8 | if(m_sectionVariable==-1) { |
1191 | ✗ | FEL_ERROR("Warning: case file contains no VARIABLE section") | |
1192 | } | ||
1193 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8 | if(m_sectionTime==-1) { |
1194 | ✗ | std::cout << "Warning: case file contains no TIME section" << std::endl; | |
1195 | } | ||
1196 | #undef DEBUGFORMAT | ||
1197 | #ifdef DEBUGFORMAT | ||
1198 | std::cout << "format : " << m_sectionFormat << std::endl; | ||
1199 | std::cout << "geometry : " << m_sectionGeometry<< std::endl; | ||
1200 | std::cout << "variable : " << m_sectionVariable << std::endl; | ||
1201 | std::cout << "time : " << m_sectionTime << std::endl; | ||
1202 | #endif | ||
1203 | |||
1204 | //==================== | ||
1205 | // Read FORMAT section | ||
1206 | //==================== | ||
1207 | /* | ||
1208 | This section is required; it specifies the data type. | ||
1209 | FORMAT | ||
1210 | type: ensight gold | ||
1211 | */ | ||
1212 | |||
1213 | //====================== | ||
1214 | // Read GEOMETRY section | ||
1215 | //====================== | ||
1216 | /* | ||
1217 | This is a required section. It describes the geometry of the data. Furthermore it can describe periodic match file if used, | ||
1218 | a boundary file if used, rigid body file if used, and vector glyph file if used. | ||
1219 | GEOMETRY | ||
1220 | model: [ts] [fs] filename [change_coords_only [cstep]] | ||
1221 | measured: [ts] [fs] filename [change_coords_only] | ||
1222 | match: filename | ||
1223 | boundary: filename | ||
1224 | rigid_body: filename | ||
1225 | Vector_glyphs: filename | ||
1226 | |||
1227 | where: | ||
1228 | ts = a time set number as specified in TIME section, ( optional ). | ||
1229 | fs = a corresponding file set number; specified in the FILE section. | ||
1230 | If an fs number is specified, then a ts is required. | ||
1231 | filename = The declared filename. | ||
1232 | - Wildcard symbols, * , are NOT USED for model or measured files that are static, ( or if written in the Single File Format). | ||
1233 | Furthermore, wildcard symbols are not used for match, boundary, or rigid_body filenames. | ||
1234 | - Wildcard symbols ARE USED for model or measured changing geometry written to multiple files. | ||
1235 | - Model filenames with structured block continuation options will contain % wildcards. | ||
1236 | change_coords_only = This option specifies that the changing geometry is for coordinates only; else the connectivity will | ||
1237 | also assumed to be changing and need to be specified as well. | ||
1238 | cstep = Used with change_coords_only option for the zero-based time step containing the connectivity, ( Optional ). | ||
1239 | If all time steps have connectivity, it can be omitted. If used, the remaining time steps no not need to repeat the connectivity. | ||
1240 | */ | ||
1241 | 8 | std::vector<std::string> contents; | |
1242 |
2/4✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
|
8 | split(m_line[m_sectionGeometry+1],contents," "); |
1243 | 8 | bool has_a_cstep=false; | |
1244 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
8 | if(contents[0] == "model:") { |
1245 | 8 | m_change_coords_only = false; | |
1246 | 8 | m_change_coords_only_cstep = 0; | |
1247 | 8 | const std::size_t dim = contents.size(); | |
1248 |
2/2✓ Branch 0 taken 24 times.
✓ Branch 1 taken 8 times.
|
32 | for(std::size_t j=0; j<dim; j++) { |
1249 | 24 | found= contents[j].find("change_coords_only"); | |
1250 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
|
24 | if(found!=std::string::npos) { |
1251 | ✗ | m_change_coords_only = true; | |
1252 | ✗ | if(j==dim-2) { | |
1253 | ✗ | has_a_cstep = true; | |
1254 | ✗ | m_change_coords_only_cstep = std::atoi(contents[dim-1].c_str()); | |
1255 | } | ||
1256 | } | ||
1257 | } | ||
1258 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8 | if(m_change_coords_only) { |
1259 | // change_coords_only | ||
1260 | ✗ | if(has_a_cstep) { | |
1261 | // cstep | ||
1262 | ✗ | if(dim == 4) { | |
1263 | ✗ | m_model_time_set = 0; | |
1264 | ✗ | m_model_file_set = 0; | |
1265 | ✗ | m_geo_file = contents[1]; | |
1266 | ✗ | } else if(dim == 5) { | |
1267 | ✗ | m_model_time_set = std::atoi(contents[1].c_str()); | |
1268 | ✗ | m_model_file_set = 0; | |
1269 | ✗ | m_geo_file = contents[2]; | |
1270 | ✗ | } else if(dim == 6) { | |
1271 | ✗ | m_model_time_set = std::atoi(contents[1].c_str()); | |
1272 | ✗ | m_model_file_set = std::atoi(contents[2].c_str()); | |
1273 | ✗ | m_geo_file = contents[3]; | |
1274 | } | ||
1275 | } else { | ||
1276 | // no cstep | ||
1277 | ✗ | if(dim == 3) { | |
1278 | ✗ | m_model_time_set = 0; | |
1279 | ✗ | m_model_file_set = 0; | |
1280 | ✗ | m_geo_file = contents[1]; | |
1281 | ✗ | } else if(dim == 4) { | |
1282 | ✗ | m_model_time_set = std::atoi(contents[1].c_str()); | |
1283 | ✗ | m_model_file_set = 0; | |
1284 | ✗ | m_geo_file = contents[2]; | |
1285 | ✗ | } else if(dim == 5) { | |
1286 | ✗ | m_model_time_set = std::atoi(contents[1].c_str()); | |
1287 | ✗ | m_model_file_set = std::atoi(contents[2].c_str()); | |
1288 | ✗ | m_geo_file = contents[3]; | |
1289 | } | ||
1290 | } | ||
1291 | } else { | ||
1292 | // no change_coords_only | ||
1293 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8 | if(dim == 2) { |
1294 | ✗ | m_model_time_set = 0; | |
1295 | ✗ | m_model_file_set = 0; | |
1296 | ✗ | m_geo_file = contents[1]; | |
1297 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | } else if(dim == 3) { |
1298 | 8 | m_model_time_set = std::atoi(contents[1].c_str()); | |
1299 | 8 | m_model_file_set = 0; | |
1300 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
8 | m_geo_file = contents[2]; |
1301 | ✗ | } else if(dim == 4) { | |
1302 | ✗ | m_model_time_set = std::atoi(contents[1].c_str()); | |
1303 | ✗ | m_model_file_set = std::atoi(contents[2].c_str()); | |
1304 | ✗ | m_geo_file = contents[3]; | |
1305 | } | ||
1306 | } | ||
1307 | } else { | ||
1308 | ✗ | std::ostringstream msg; | |
1309 | ✗ | msg << contents[0] << " not yet implemented"; | |
1310 | ✗ | FEL_ERROR(msg.str()) | |
1311 | } | ||
1312 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | m_num_wildcard = CountOccurenceChar(m_geo_file,'*'); |
1313 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
8 | if(m_num_wildcard) m_geo_file_wildcard = m_geo_file; |
1314 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | else m_geo_file_wildcard = ""; |
1315 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
|
8 | if(CountOccurenceChar(m_geo_file,'%')) { |
1316 | ✗ | FEL_ERROR("Wildcard % not yet implemented ") | |
1317 | } | ||
1318 |
1/4✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
8 | if(m_geo_file_wildcard != "") m_geo_file = ReplaceWilcardByInt(m_geo_file_wildcard, 198, '*'); |
1319 | |||
1320 | #undef DEBUGGEO | ||
1321 | #ifdef DEBUGGEO | ||
1322 | std::cout << "GEOMETRY" << std::endl; | ||
1323 | std::cout << "\t model:" << std::endl; | ||
1324 | std::cout << "\t model_time_set = " << m_model_time_set << std::endl; | ||
1325 | std::cout << "\t mode_file_set = " << m_model_file_set << std::endl; | ||
1326 | std::cout << "\t geo_file = " << m_geo_file << std::endl; | ||
1327 | std::cout << "\t geo_file_wildcard = " << m_geo_file_wildcard << std::endl; | ||
1328 | std::cout << "\t change_coords_only = " << m_change_coords_only << std::endl; | ||
1329 | std::cout << "\t change_coords_only_cstep = " << m_change_coords_only_cstep << std::endl; | ||
1330 | #endif | ||
1331 | //====================== | ||
1332 | // Read VARIABLE section | ||
1333 | //====================== | ||
1334 | /* | ||
1335 | This section of the ASCII case file is optional. If declared, it specifies the filenames and variables of the data. | ||
1336 | The EnSight Gold Casefile Format allows for 300 variables to be declared. | ||
1337 | Here's an example | ||
1338 | |||
1339 | VARIABLE | ||
1340 | constant per case: [ts] description const_value(s) | ||
1341 | constant per case file: [ts] description cvfilename | ||
1342 | scalar per node: [ts] [fs] description filename | ||
1343 | vector per node: [ts] [fs] description filename | ||
1344 | tensor symm per node: [ts] [fs] description filename | ||
1345 | tensor asym per node: [ts] [fs] description filename | ||
1346 | scalar per element: [ts] [fs] description filename | ||
1347 | vector per element: [ts] [fs] description filename | ||
1348 | tensor symm per element: [ts] [fs] description filename | ||
1349 | tensor asym per element: [ts] [fs] description filename | ||
1350 | scalar per measured node: [ts] [fs] description filename | ||
1351 | vector per measured node: [ts] [fs] description filename | ||
1352 | complex scalar per node: [ts] [fs] description Re_fn Im_fn freq | ||
1353 | complex vector per node: [ts] [fs] description Re_fn Im_fn freq | ||
1354 | complex scalar per element: [ts] [fs] description Re_fn Im_fn freq | ||
1355 | complex vector per element: [ts] [fs] description Re_fn Im_fn freq | ||
1356 | |||
1357 | |||
1358 | where: | ||
1359 | ts = The corresponding time set number ( or index ) as specified in the TIME section. | ||
1360 | fs = The corresponding file set number ( Or index ) as specified in the FILE section. | ||
1361 | description = This will be the variable name presented by the GUI. | ||
1362 | const_value(s) = If constants change over time then ns in TIME section below; else ts for constant, | ||
1363 | cvfilename = The constant values filename, that contains the actual constant values. | ||
1364 | Re_fn = The real values filename, that contains the real parts of a complex variable. | ||
1365 | Im_fn = The imaginary values filename, that contains the imaginary parts of a complex variable. | ||
1366 | freq = The corresponding harmonic frequency of the complex variable. UNDEFINED may be used as an acceptable | ||
1367 | value if it's undefined. | ||
1368 | Notes: | ||
1369 | As many variable lines as needed may be used. | ||
1370 | Variable descriptions have the following restrictions: | ||
1371 | - 19 characters | ||
1372 | - duplicates not allowed | ||
1373 | - leading or trailing whitespace is disguarded | ||
1374 | - must not start with a digit | ||
1375 | - must not contain any of the following reserved characters | ||
1376 | ( [ + @ ! * $ ) ] - space # ^ / | ||
1377 | */ | ||
1378 | 8 | m_num_variable = m_sectionTime - m_sectionVariable - 1; | |
1379 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | m_var.resize(m_num_variable); |
1380 | 8 | std::string typevar,restofline,description,filename; | |
1381 | 8 | int time_set = 0; | |
1382 | 8 | int file_set = 0; | |
1383 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8 times.
|
20 | for(int j=0; j<m_num_variable; j++) { |
1384 | 12 | found = m_line[m_sectionVariable+1+j].find(':'); | |
1385 |
1/2✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
|
12 | typevar = m_line[m_sectionVariable+1+j].substr(0,found); |
1386 |
1/2✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
|
12 | restofline = m_line[m_sectionVariable+1+j].substr(found+1,m_line[m_sectionVariable+1+j].size()-found-1); |
1387 |
2/4✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
|
12 | split(restofline,contents," "); |
1388 | |||
1389 | 12 | const std::size_t contents_size = contents.size(); | |
1390 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(contents_size == 4) { |
1391 | ✗ | time_set = std::atoi(contents[0].c_str()); | |
1392 | ✗ | file_set = std::atoi(contents[1].c_str()); | |
1393 | ✗ | description = contents[2]; | |
1394 | ✗ | filename = contents[3]; | |
1395 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | } else if(contents_size == 3) { |
1396 | 12 | time_set = std::atoi(contents[0].c_str()); | |
1397 | 12 | file_set = -1; | |
1398 |
1/2✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
|
12 | description = contents[1]; |
1399 |
1/2✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
|
12 | filename = contents[2]; |
1400 | ✗ | } else if(contents_size == 2) { | |
1401 | ✗ | time_set = -1; | |
1402 | ✗ | file_set = -1; | |
1403 | ✗ | description = contents[0]; | |
1404 | ✗ | filename = contents[1]; | |
1405 | } | ||
1406 |
1/2✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
|
12 | m_var[j] = EnsightVariable(typevar,time_set,file_set,description,filename); |
1407 | } | ||
1408 | //====================== | ||
1409 | // Read TIME section | ||
1410 | //====================== | ||
1411 | /* | ||
1412 | This is an optional section for steady state cases. For transient cases, it is required. It describes time set information. | ||
1413 | Below are three example usages: | ||
1414 | |||
1415 | TIME | ||
1416 | time set: ts [description] | ||
1417 | number of steps: ns | ||
1418 | filename start number: fs | ||
1419 | filename increment: fi | ||
1420 | time values: time_1 time_2 .... time_ns | ||
1421 | TIME | ||
1422 | time set: ts [description] | ||
1423 | number of steps: ns | ||
1424 | filename numbers: fn | ||
1425 | time values: time_1 time_2 .... time_ns | ||
1426 | TIME | ||
1427 | time set: ts [description] | ||
1428 | number of steps: ns | ||
1429 | filename numbers file: fnfilename | ||
1430 | time values file: tvfilename | ||
1431 | |||
1432 | where: | ||
1433 | ts = timeset number. This is the number referenced in the GEOMETRY and VARIABLE sections. description = optional timeset | ||
1434 | description which will be shown in userinterface. | ||
1435 | ns = number of transient steps | ||
1436 | fs = the number to replace the “*” wildcards in the filenames, for the first step | ||
1437 | fi = the increment to fs for subsequent steps | ||
1438 | time = the actual time values for each step, each of which must be separated by a white space and which may continue on | ||
1439 | the next line if needed | ||
1440 | fn = a list of numbers or indices, to replace the “*” wildcards in the filenames. | ||
1441 | fnfilename = name of file containing ns filename numbers (fn). | ||
1442 | tvfilename = name of file containing the time values(time_1 ... time_ns). | ||
1443 | */ | ||
1444 | |||
1445 | //!\todo Several time sets | ||
1446 | |||
1447 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | m_time.resize(1); |
1448 | 8 | int ilgn,num_steps = 0; | |
1449 | 8 | int filename_start_number = 0; | |
1450 | 8 | int filename_increment = 0; | |
1451 | // | ||
1452 | 8 | ilgn = m_sectionTime+1; | |
1453 | 8 | found = m_line[ilgn].find(':'); | |
1454 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
8 | typevar = m_line[ilgn].substr(0,found); |
1455 |
1/2✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | restofline = m_line[ilgn].substr(found+1,m_line[ilgn].size()-found-1); |
1456 |
2/4✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
|
8 | split(restofline,contents," "); |
1457 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | if(typevar == "time set") { |
1458 | 8 | time_set = std::atoi(contents[0].c_str()); | |
1459 | } else { | ||
1460 | ✗ | std::ostringstream msg; | |
1461 | ✗ | msg << "Read: " << typevar << ", Expected: time set"; | |
1462 | ✗ | FEL_ERROR(msg.str()) | |
1463 | } | ||
1464 | 8 | ilgn = m_sectionTime+2; | |
1465 | 8 | found = m_line[ilgn].find(':'); | |
1466 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
8 | typevar = m_line[ilgn].substr(0,found); |
1467 |
1/2✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | restofline = m_line[ilgn].substr(found+1,m_line[ilgn].size()-found-1); |
1468 |
2/4✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
|
8 | split(restofline,contents," "); |
1469 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | if(typevar == "number of steps"){ |
1470 | 8 | num_steps = std::atoi(contents[0].c_str()); | |
1471 | } else { | ||
1472 | ✗ | std::ostringstream msg; | |
1473 | ✗ | msg << "Read: " << typevar << ", Expected: number of steps "; | |
1474 | ✗ | FEL_ERROR(msg.str()) | |
1475 | } | ||
1476 | 8 | ilgn = m_sectionTime+3; | |
1477 | 8 | found = m_line[ilgn].find(':'); | |
1478 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
8 | typevar = m_line[ilgn].substr(0,found); |
1479 |
1/2✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | restofline = m_line[ilgn].substr(found+1,m_line[ilgn].size()-found-1); |
1480 | //StringSplit(restofline," \t",contents);// delimiter is either a space or a tab | ||
1481 | |||
1482 |
2/4✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
|
8 | split(restofline,contents," "); |
1483 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | if(typevar == "filename start number") { |
1484 | 8 | filename_start_number = std::atoi(contents[0].c_str()); | |
1485 | } else { | ||
1486 | ✗ | std::ostringstream msg; | |
1487 | ✗ | msg << "Read: " << typevar << ", Expected: file name start number"; | |
1488 | ✗ | FEL_ERROR(msg.str()) | |
1489 | } | ||
1490 | 8 | ilgn = m_sectionTime+4; | |
1491 | 8 | found = m_line[ilgn].find(':'); | |
1492 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
8 | typevar = m_line[ilgn].substr(0,found); |
1493 |
1/2✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | restofline = m_line[ilgn].substr(found+1,m_line[ilgn].size()-found-1); |
1494 |
2/4✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
|
8 | split(restofline,contents," "); |
1495 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | if(typevar == "filename increment") |
1496 | 8 | filename_increment = std::atoi(contents[0].c_str()); | |
1497 | else { | ||
1498 | ✗ | std::ostringstream msg; | |
1499 | ✗ | msg << "Read: " << typevar << ", Expected: file name increment"; | |
1500 | ✗ | FEL_ERROR(msg.str()) | |
1501 | } | ||
1502 | // | ||
1503 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | m_time[0] = EnsightTimeBis(time_set,num_steps,filename_start_number,filename_increment); |
1504 | // | ||
1505 | 8 | ilgn = m_sectionTime+5; | |
1506 | 8 | found = m_line[ilgn].find(':'); | |
1507 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
8 | typevar = m_line[ilgn].substr(0,found); |
1508 |
1/2✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | restofline = m_line[ilgn].substr(found+1,m_line[ilgn].size()-found-1); |
1509 |
2/4✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
|
8 | split(restofline,contents," "); |
1510 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | if(typevar == "time values") { |
1511 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | std::stringstream buftime; |
1512 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 2 taken 8 times.
|
20 | for(unsigned int iline = m_sectionTime+6; iline< m_line.size(); iline++) { |
1513 |
1/2✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
|
12 | buftime << m_line[iline]; |
1514 | } | ||
1515 | // std::cout << buftime.str()<< std::endl; | ||
1516 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 8 times.
|
56 | for(int j=0; j<num_steps; j++) { |
1517 |
1/2✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
|
48 | buftime >> m_time[0].timeValue(j); |
1518 | } | ||
1519 | 8 | } else { | |
1520 | ✗ | std::ostringstream msg; | |
1521 | ✗ | msg << "Read: " << typevar << ", Expected: time values"; | |
1522 | ✗ | FEL_ERROR(msg.str()) | |
1523 | } | ||
1524 | |||
1525 | //====================== | ||
1526 | // Read FILE section | ||
1527 | //====================== | ||
1528 | /* | ||
1529 | This section is optional. It's used for multiple time step data written with the single-file option. This section | ||
1530 | will specify the number of time steps for each file, for each data entity ( meaning for each geometry and each | ||
1531 | variable, model and/or measured). | ||
1532 | If the operation system imposed a maximum file size limit, and the data exceeds this limit, then a data entity | ||
1533 | will use as many continuation files as needed. Each file set corresponds to one and only one time set, but a time | ||
1534 | set may be referenced by many file sets. | ||
1535 | Usage: | ||
1536 | FILE | ||
1537 | file set: fs | ||
1538 | filename index: fi # Note: only used when data continues in other files | ||
1539 | number of steps: ns | ||
1540 | |||
1541 | where: | ||
1542 | fs = file set number. This is the same number referenced in the GEOMETRY and VARIABLE sections. | ||
1543 | ns = number of transient steps. | ||
1544 | fi = file index number in the file name ( This replaces "*" in the filenames ). | ||
1545 | Material Section | ||
1546 | */ | ||
1547 | |||
1548 | //====================== | ||
1549 | // Read MATERIAL section | ||
1550 | //====================== | ||
1551 | /* | ||
1552 | Material Section | ||
1553 | |||
1554 | This is an optional section. It provides information for the material interface part case. Currently, as of version 8.2, EnSight supports a single material set. | ||
1555 | Usage: | ||
1556 | MATERIAL | ||
1557 | material set number: ms [description] | ||
1558 | material id count: nm | ||
1559 | material id numbers: matno_1 matno_2 ... matno_nm | ||
1560 | material id names: matdesc_1 mat_2 ... mat_nm | ||
1561 | material id per element: [ts] [fs] filename | ||
1562 | material mixed ids: [ts] [fs] filename | ||
1563 | material mixed values: [ts] [fs] filename | ||
1564 | # optional species parameters | ||
1565 | species id count: ns | ||
1566 | species id numbers: spno_1 spno_2 … spno_ns | ||
1567 | species id names: spdesc_1 spdesc_2 … spdesc_ns | ||
1568 | species per material counts: sp_1 sp_2 … sp_nm | ||
1569 | species per material lists: matno_1_sp_1 matno_1_sp_2 … matno_1_sp_sp_1 | ||
1570 | matno_2_sp_1 matno_2_sp_2 … matno_2_sp_sp_2 | ||
1571 | … | ||
1572 | matno_nm_sp_1 matno_nm_sp2 … matno_nm_sp_sp_nm | ||
1573 | (Note: above concatenated lists do not have to be on | ||
1574 | separate lines.) | ||
1575 | |||
1576 | species element values: [ts] [fs] sp_filename | ||
1577 | |||
1578 | where: | ||
1579 | ts = The time set number, the same as declared in the TIME section. Only required for transient materials. | ||
1580 | fs = The file set number, the same as declared in the FILE section. ( Note: if fs is specified, then ts becomes mandatory vs optional. | ||
1581 | ms = The material set number, ( although at this time only one material set is supported ). | ||
1582 | nm = The number of materials for this set. | ||
1583 | matno = The material number used from the material and mixed-material id file. There is a total of nm of these. Non-positive materials are all grouped together into a null-material. | ||
1584 | matdesc = The GUI's material description or the nm matno above. | ||
1585 | filename = The material filename. | ||
1586 | ns = The number of species for the set. | ||
1587 | spno = The "species per material list:" specification. There should be ns of these positive integers. | ||
1588 | spdesc = The GUI description corresponding to the ns spno's. | ||
1589 | spm = The "number of species per material number" (matno); an entry of "0" is valid if no species exist for a given material | ||
1590 | matno_#m_sp = Specie id number ( spno) list member for this material number id ( matno ). If no species for this material, then proceed to next material that has species. | ||
1591 | sp_filename = The filename of the appropriate "species element values:" file. | ||
1592 | */ | ||
1593 | |||
1594 | //====================== | ||
1595 | // Read BLOCK_CONTINUATION section | ||
1596 | //====================== | ||
1597 | /* | ||
1598 | Block Continuation Section | ||
1599 | |||
1600 | This is an optional section, used for grouping structured blocks together. The purpose of this is to allow the capability to be able to read N number of files using M number of cluster notes, where N > M. The filenames of the geometry and variables must comtain "%" wildcards if this option is used. | ||
1601 | |||
1602 | Usage: | ||
1603 | |||
1604 | BLOCK_CONTINUATION | ||
1605 | number of sets: ns | ||
1606 | filename start number: fs | ||
1607 | filename increment: fi | ||
1608 | |||
1609 | where: | ||
1610 | ns = The number of contiguous partioned structured files. | ||
1611 | fs = the number to replace the "%" wildcard in the geometry and variable filename, for the first set. | ||
1612 | fi = the increment to fs for subsequent sets. | ||
1613 | |||
1614 | |||
1615 | */ | ||
1616 | 8 | } | |
1617 | 468 | } | |
1618 | |||
1619 | /***********************************************************************************/ | ||
1620 | /***********************************************************************************/ | ||
1621 | |||
1622 | ✗ | std::string EnsightCase::geometryFile() const | |
1623 | { | ||
1624 | ✗ | if(m_geo_file_wildcard!="") { | |
1625 | ✗ | std::ostringstream msg; | |
1626 | ✗ | msg << "Geometry file contains wildcard characters " << m_geo_file_wildcard | |
1627 | ✗ | << "Use EnsightCase::geometryFile(int i) to specify the time step"; | |
1628 | ✗ | FEL_ERROR(msg.str()) | |
1629 | } | ||
1630 | ✗ | return m_geo_file; | |
1631 | } | ||
1632 | |||
1633 | /***********************************************************************************/ | ||
1634 | /***********************************************************************************/ | ||
1635 | |||
1636 | ✗ | std::string EnsightCase::geometryFile(int i) const | |
1637 | { | ||
1638 | ✗ | if(m_geo_file_wildcard == "") { | |
1639 | ✗ | return m_geo_file; | |
1640 | } else { | ||
1641 | ✗ | return ReplaceWilcardByInt(m_geo_file_wildcard, i, '*'); | |
1642 | } | ||
1643 | } | ||
1644 | |||
1645 | /***********************************************************************************/ | ||
1646 | /***********************************************************************************/ | ||
1647 | |||
1648 | ✗ | int EnsightCase::variableIndex(std::string description) const | |
1649 | { | ||
1650 | ✗ | for(unsigned int i=0; i<m_var.size(); i++) { | |
1651 | ✗ | if(m_var[i].description()==description) return i; | |
1652 | } | ||
1653 | ✗ | std::ostringstream msg; | |
1654 | ✗ | msg << "Variable " << description << " is not in the case file"; | |
1655 | ✗ | FEL_ERROR(msg.str()) | |
1656 | ✗ | return 0; | |
1657 | } | ||
1658 | |||
1659 | /***********************************************************************************/ | ||
1660 | /***********************************************************************************/ | ||
1661 | |||
1662 | 24 | int EnsightCase::timeIndex(double time) const | |
1663 | { | ||
1664 | 24 | return m_time[0].timeIndex(time); | |
1665 | } | ||
1666 | |||
1667 | /***********************************************************************************/ | ||
1668 | /***********************************************************************************/ | ||
1669 | |||
1670 | ✗ | int EnsightCase::getNumNodeFromGeoFile(std::string dir) const | |
1671 | { | ||
1672 | char line[1024]; | ||
1673 | int numNode; | ||
1674 | ✗ | std::string geofilepath = dir + "/" + geometryFile(); | |
1675 | ✗ | std::ifstream geofile(geofilepath.c_str()); | |
1676 | ✗ | if(!geofile) { | |
1677 | ✗ | std::ostringstream msg; | |
1678 | ✗ | msg << "Cannot open " << geometryFile(); | |
1679 | ✗ | FEL_ERROR(msg.str()) | |
1680 | } | ||
1681 | ✗ | for(int i=0; i<5; i++) geofile.getline(line,1024); | |
1682 | ✗ | geofile >> numNode; | |
1683 | ✗ | return numNode; | |
1684 | } | ||
1685 | |||
1686 | /***********************************************************************************/ | ||
1687 | /***********************************************************************************/ | ||
1688 | |||
1689 | 45 | void EnsightCase::SetDomainDim_case(int domainDim) | |
1690 | { | ||
1691 | 45 | m_domainDim = domainDim; | |
1692 | 45 | } | |
1693 | |||
1694 | /***********************************************************************************/ | ||
1695 | /***********************************************************************************/ | ||
1696 | |||
1697 | 45 | void EnsightCase::SetCreateNormalTangent_case(bool createNormalTangent) | |
1698 | { | ||
1699 | 45 | m_createNormalTangent = createNormalTangent; | |
1700 | 45 | } | |
1701 | |||
1702 | /***********************************************************************************/ | ||
1703 | /***********************************************************************************/ | ||
1704 | |||
1705 | 4 | void EnsightCase::readScalar(const std::string& fileName, double* vec, | |
1706 | felInt size) | ||
1707 | { | ||
1708 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | FILE* pFile = fopen (fileName.c_str(),"r"); |
1709 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (pFile==nullptr) { |
1710 | ✗ | FEL_ERROR("Impossible to read "+fileName +"."); | |
1711 | } | ||
1712 | char str[80]; | ||
1713 | 4 | std::string display; | |
1714 |
2/4✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
|
4 | if ( fscanf(pFile,"%s", str) !=1 ) { |
1715 | ✗ | FEL_ERROR("Failed to read str"); | |
1716 | } | ||
1717 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | display = str;//scalar |
1718 | |||
1719 |
2/4✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
|
4 | if ( fscanf(pFile,"%s", str) !=1 ) { |
1720 | ✗ | FEL_ERROR("Failed to read str"); | |
1721 | } | ||
1722 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | display = str;//per |
1723 | |||
1724 |
2/4✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
|
4 | if ( fscanf(pFile,"%s", str) !=1 ) { |
1725 | ✗ | FEL_ERROR("Failed to read str"); | |
1726 | } | ||
1727 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | display = str;//node |
1728 | |||
1729 | //Read value | ||
1730 | 4 | int count = 0; | |
1731 |
2/2✓ Branch 0 taken 568 times.
✓ Branch 1 taken 4 times.
|
572 | for ( felInt i = 0; i < size; i++) { |
1732 |
2/4✓ Branch 1 taken 568 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 568 times.
|
568 | if ( fscanf(pFile,"%lf", &vec[i]) !=1 ) { |
1733 | ✗ | FEL_ERROR("Failed to read scalar"); | |
1734 | } | ||
1735 | // std::cout << vec[i] << std::endl; | ||
1736 |
2/2✓ Branch 0 taken 92 times.
✓ Branch 1 taken 476 times.
|
568 | if ( count == 6 ) { |
1737 |
2/4✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 92 times.
|
92 | if ( fscanf( pFile, "\n" ) != 0) { |
1738 | ✗ | FEL_ERROR("Failed to read"); | |
1739 | } | ||
1740 | 92 | count=0; | |
1741 | } | ||
1742 | 568 | count++; | |
1743 | } | ||
1744 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | fclose(pFile); |
1745 | 4 | } | |
1746 | |||
1747 | /***********************************************************************************/ | ||
1748 | /***********************************************************************************/ | ||
1749 | |||
1750 | 20 | void EnsightCase::readVector(const std::string& fileName, double* vec, | |
1751 | felInt size) | ||
1752 | { | ||
1753 |
1/2✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
|
20 | FILE* pFile = fopen (fileName.c_str(),"r"); |
1754 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
|
20 | if (pFile==nullptr) { |
1755 | ✗ | FEL_ERROR("Impossible to read "+fileName +"."); | |
1756 | } | ||
1757 | char str[80]; | ||
1758 | 20 | std::string display; | |
1759 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
|
20 | if ( fscanf(pFile,"%s", str) !=1 ) { |
1760 | ✗ | FEL_WARNING("Failed to read str"); | |
1761 | } | ||
1762 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | display = str; |
1763 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
|
20 | if ( fscanf(pFile,"%s", str) !=1 ) { |
1764 | ✗ | FEL_WARNING("Failed to read str"); | |
1765 | } | ||
1766 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | display = str; |
1767 |
2/4✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
|
20 | if ( fscanf(pFile,"%s", str) !=1) { |
1768 | ✗ | FEL_WARNING("Failed to read str"); | |
1769 | } | ||
1770 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | display = str; |
1771 | //Read value | ||
1772 | 20 | int count = 0; | |
1773 |
2/2✓ Branch 0 taken 8520 times.
✓ Branch 1 taken 20 times.
|
8540 | for ( felInt i = 0; i < size; i++) { |
1774 |
2/4✓ Branch 1 taken 8520 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 8520 times.
|
8520 | if ( fscanf(pFile,"%lf", &vec[i]) !=1 ) { |
1775 | ✗ | FEL_WARNING("Failed to read vec"); | |
1776 | } | ||
1777 |
2/2✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 7120 times.
|
8520 | if ( count == 6 ) { |
1778 |
2/4✓ Branch 1 taken 1400 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1400 times.
|
1400 | if ( fscanf( pFile, "\n" ) !=0 ) { |
1779 | ✗ | FEL_WARNING("Failed to read"); | |
1780 | } | ||
1781 | 1400 | count=0; | |
1782 | } | ||
1783 | 8520 | count++; | |
1784 | } | ||
1785 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | fclose(pFile); |
1786 | 20 | } | |
1787 | |||
1788 | /***********************************************************************************/ | ||
1789 | /***********************************************************************************/ | ||
1790 | |||
1791 | 24 | void EnsightCase::readVariable(int idVariable,int indexTime, double* vec,felInt size) | |
1792 | { | ||
1793 |
2/6✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
24 | if (m_directory.at(m_directory.length()-1) != '/') m_directory += '/'; |
1794 |
2/4✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 24 times.
✗ Branch 6 not taken.
|
24 | const std::string fileName = m_directory + m_var[idVariable].variableFileInput(indexTime); |
1795 |
1/2✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
|
24 | const std::string fileNameExt = fileName.substr( fileName.find_last_of( '.' ) +1); |
1796 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 20 times.
|
24 | if (fileNameExt == "scl") { |
1797 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | readScalar(fileName, vec, size); |
1798 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | } else if (fileNameExt == "vct") { |
1799 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | readVector(fileName, vec, size); |
1800 | } else { | ||
1801 | ✗ | FEL_ERROR("This type of file is not readable at the moment."); | |
1802 | } | ||
1803 | 24 | } | |
1804 | |||
1805 | /***********************************************************************************/ | ||
1806 | /***********************************************************************************/ | ||
1807 | |||
1808 | 5378 | void EnsightCase::addVariable(const EnsightVariable::TypeVar& type, const std::string& nameVariable, | |
1809 | const double* solution, felInt size, bool manageMemory) | ||
1810 | { | ||
1811 |
1/2✓ Branch 1 taken 5378 times.
✗ Branch 2 not taken.
|
5378 | EnsightVariable var(type,nameVariable, solution,size,manageMemory); |
1812 |
1/2✓ Branch 1 taken 5378 times.
✗ Branch 2 not taken.
|
5378 | m_var.push_back(var); |
1813 | 5378 | } | |
1814 | |||
1815 | /***********************************************************************************/ | ||
1816 | /***********************************************************************************/ | ||
1817 | |||
1818 | ✗ | void EnsightCase::writeVariable(const std::string& outputDirectory, const std::string& nameVariable, int indexTime) | |
1819 | { | ||
1820 | ✗ | for (std::size_t iVar = 0; iVar < m_var.size(); iVar++) { | |
1821 | ✗ | if (strcmp(m_var[iVar].description().c_str(),nameVariable.c_str()) == 0) { | |
1822 | ✗ | m_var[iVar].write(outputDirectory, indexTime); | |
1823 | } else { | ||
1824 | ✗ | FEL_ERROR("This variable doesn't exist."); | |
1825 | } | ||
1826 | } | ||
1827 | } | ||
1828 | |||
1829 | /***********************************************************************************/ | ||
1830 | /***********************************************************************************/ | ||
1831 | |||
1832 | 3112 | void EnsightCase::writeCaseFile(const std::string& outputDirectory, | |
1833 | const std::string& nameCase, | ||
1834 | int optionMultiCase) | ||
1835 | { | ||
1836 | // int domainDim = domainDim(); | ||
1837 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3112 times.
|
3112 | if (optionMultiCase == 1) { |
1838 | ✗ | for (std::size_t iVar = 0; iVar < m_var.size(); iVar++) { | |
1839 | FILE * pFile; | ||
1840 | ✗ | const std::string fileName = outputDirectory + "/" + m_var[iVar].description() +".case"; | |
1841 | ✗ | pFile = fopen (fileName.c_str(),"w"); | |
1842 | ✗ | if (pFile==nullptr) { | |
1843 | ✗ | FEL_ERROR("Impossible to write "+fileName+" case file"); | |
1844 | } | ||
1845 | |||
1846 | ✗ | fprintf( pFile,"FORMAT\n"); | |
1847 | ✗ | if(FelisceParam::instance().outputFileFormat == ENSIGHT6) | |
1848 | ✗ | fprintf( pFile,"type: ensight\n"); | |
1849 | ✗ | else if(FelisceParam::instance().outputFileFormat == ENSIGHTGOLD) | |
1850 | ✗ | fprintf( pFile,"type: ensight gold\n"); | |
1851 | else | ||
1852 | ✗ | FEL_ERROR("Unknown output file format"); | |
1853 | |||
1854 | ✗ | case_mesh_by_variable(pFile, iVar); | |
1855 | ✗ | case_variable_by_variable( pFile, iVar); | |
1856 | ✗ | if (m_createNormalTangent) case_geometricVec(pFile); | |
1857 | ✗ | case_time_section( pFile); | |
1858 | ✗ | fclose( pFile); | |
1859 | } | ||
1860 |
2/2✓ Branch 0 taken 44 times.
✓ Branch 1 taken 3068 times.
|
3112 | } else if(optionMultiCase == 2) { |
1861 | FILE * pFile; | ||
1862 |
3/6✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 44 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 44 times.
✗ Branch 8 not taken.
|
88 | const std::string fileName = outputDirectory + "/" + nameCase +".case"; |
1863 |
1/2✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
|
44 | pFile = fopen (fileName.c_str(),"w"); |
1864 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
|
44 | if (pFile==nullptr) { |
1865 | ✗ | const std::string command = "mkdir -p " + outputDirectory; | |
1866 | ✗ | const int ierr = system(command.c_str()); | |
1867 | ✗ | if (ierr>0) { | |
1868 | ✗ | FEL_ERROR("Impossible to write "+fileName+" medit mesh"); | |
1869 | } | ||
1870 | ✗ | pFile = fopen (fileName.c_str(),"w"); | |
1871 | } | ||
1872 | |||
1873 |
1/2✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
|
44 | fprintf( pFile,"FORMAT\n"); |
1874 |
2/4✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
|
44 | if(FelisceParam::instance().outputFileFormat == ENSIGHT6) |
1875 |
1/2✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
|
44 | fprintf( pFile,"type: ensight\n"); |
1876 | ✗ | else if(FelisceParam::instance().outputFileFormat == ENSIGHTGOLD) | |
1877 | ✗ | fprintf( pFile,"type: ensight gold\n"); | |
1878 | else | ||
1879 | ✗ | FEL_ERROR("Unknown output file format"); | |
1880 | |||
1881 |
1/2✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
|
44 | case_mesh_multiple_section(pFile); |
1882 |
1/2✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
|
44 | case_variable_section( pFile );; |
1883 |
3/4✓ Branch 0 taken 11 times.
✓ Branch 1 taken 33 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
|
44 | if (m_createNormalTangent) case_geometricVec(pFile); |
1884 |
1/2✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
|
44 | case_time_section( pFile); |
1885 |
1/2✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
|
44 | fclose( pFile); |
1886 | 44 | } else { | |
1887 | FILE * pFile; | ||
1888 |
3/6✓ Branch 1 taken 3068 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3068 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3068 times.
✗ Branch 8 not taken.
|
6136 | const std::string fileName = outputDirectory + "/" + nameCase +".case"; |
1889 |
1/2✓ Branch 2 taken 3068 times.
✗ Branch 3 not taken.
|
3068 | pFile = fopen (fileName.c_str(),"w"); |
1890 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3068 times.
|
3068 | if (pFile==nullptr) { |
1891 | ✗ | const std::string command = "mkdir -p " + outputDirectory; | |
1892 | ✗ | const int ierr = system(command.c_str()); | |
1893 | ✗ | if (ierr>0) { | |
1894 | ✗ | FEL_ERROR("Impossible to write "+fileName+" medit mesh"); | |
1895 | } | ||
1896 | ✗ | pFile = fopen (fileName.c_str(),"w"); | |
1897 | } | ||
1898 | |||
1899 |
1/2✓ Branch 1 taken 3068 times.
✗ Branch 2 not taken.
|
3068 | fprintf( pFile,"FORMAT\n"); |
1900 |
3/10✓ Branch 1 taken 3068 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3068 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 3068 times.
✗ Branch 11 not taken.
|
3068 | if( (FelisceParam::instance().outputFileFormat == ENSIGHT6) || (FelisceParam::instance().outputFileFormat == ENSIGHT6BIN)) { |
1901 |
1/2✓ Branch 1 taken 3068 times.
✗ Branch 2 not taken.
|
3068 | fprintf( pFile,"type: ensight\n"); |
1902 | ✗ | } else if(FelisceParam::instance().outputFileFormat == ENSIGHTGOLD) { | |
1903 | ✗ | fprintf( pFile,"type: ensight gold\n"); | |
1904 | } else { | ||
1905 | ✗ | FEL_ERROR("Unknown output file format"); | |
1906 | } | ||
1907 | |||
1908 |
1/2✓ Branch 1 taken 3068 times.
✗ Branch 2 not taken.
|
3068 | case_mesh_section(pFile); |
1909 |
1/2✓ Branch 1 taken 3068 times.
✗ Branch 2 not taken.
|
3068 | case_variable_section( pFile ); |
1910 |
3/4✓ Branch 0 taken 449 times.
✓ Branch 1 taken 2619 times.
✓ Branch 3 taken 449 times.
✗ Branch 4 not taken.
|
3068 | if (m_createNormalTangent) case_geometricVec(pFile); |
1911 |
1/2✓ Branch 1 taken 3068 times.
✗ Branch 2 not taken.
|
3068 | case_time_section( pFile); |
1912 |
1/2✓ Branch 1 taken 3068 times.
✗ Branch 2 not taken.
|
3068 | fclose( pFile); |
1913 | 3068 | } | |
1914 | 3112 | } | |
1915 | |||
1916 | /***********************************************************************************/ | ||
1917 | /***********************************************************************************/ | ||
1918 | |||
1919 | 3068 | void EnsightCase::case_mesh_section(FILE* pFile) | |
1920 | { | ||
1921 |
1/2✓ Branch 1 taken 3068 times.
✗ Branch 2 not taken.
|
3068 | fprintf( pFile, "GEOMETRY\n"); |
1922 |
2/4✓ Branch 1 taken 3068 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3068 times.
✗ Branch 5 not taken.
|
3068 | const std::string name = "model: 1 "+ m_geo_file +"\n"; |
1923 |
1/2✓ Branch 2 taken 3068 times.
✗ Branch 3 not taken.
|
3068 | fprintf( pFile, "%s", name.c_str()); |
1924 | 3068 | } | |
1925 | |||
1926 | /***********************************************************************************/ | ||
1927 | /***********************************************************************************/ | ||
1928 | |||
1929 | 44 | void EnsightCase::case_mesh_multiple_section(FILE* pFile) | |
1930 | { | ||
1931 |
1/2✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
|
44 | fprintf( pFile, "GEOMETRY\n"); |
1932 |
2/4✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 44 times.
✗ Branch 5 not taken.
|
44 | const std::string name = "model: 1 "+ m_geo_file +".*****.geo\n"; |
1933 |
1/2✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
|
44 | fprintf( pFile, "%s", name.c_str()); |
1934 | 44 | } | |
1935 | |||
1936 | /***********************************************************************************/ | ||
1937 | /***********************************************************************************/ | ||
1938 | |||
1939 | ✗ | void EnsightCase::case_mesh_by_variable(FILE* pFile, int iVar) | |
1940 | { | ||
1941 | ✗ | fprintf( pFile, "GEOMETRY\n"); | |
1942 | ✗ | const std::string name = "model: 1 "+ m_var[iVar].description() +".geo\n"; | |
1943 | ✗ | fprintf( pFile, "%s", name.c_str()); | |
1944 | } | ||
1945 | |||
1946 | /***********************************************************************************/ | ||
1947 | /***********************************************************************************/ | ||
1948 | |||
1949 | 3112 | void EnsightCase::case_variable_section(FILE* pFile) | |
1950 | { | ||
1951 | 3112 | std::string name; | |
1952 |
1/2✓ Branch 1 taken 3112 times.
✗ Branch 2 not taken.
|
3112 | fprintf( pFile, "VARIABLE\n"); |
1953 | |||
1954 |
2/2✓ Branch 1 taken 5378 times.
✓ Branch 2 taken 3112 times.
|
8490 | for (std::size_t iVar = 0; iVar < m_var.size(); iVar++) { |
1955 |
1/2✓ Branch 2 taken 5378 times.
✗ Branch 3 not taken.
|
5378 | name = m_var[iVar].description(); |
1956 |
2/4✓ Branch 2 taken 1623 times.
✓ Branch 3 taken 3755 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
5378 | switch( m_var[iVar].type() ) { |
1957 | 1623 | case EnsightVariable::ScalarPerNode: | |
1958 |
4/8✓ Branch 1 taken 1623 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1623 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1623 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1623 times.
✗ Branch 11 not taken.
|
1623 | name = "scalar per node: 1 "+name+" "+name+".*****.scl\n"; |
1959 |
1/2✓ Branch 2 taken 1623 times.
✗ Branch 3 not taken.
|
1623 | fprintf( pFile, "%s", name.c_str()); |
1960 | 1623 | break; | |
1961 | 3755 | case EnsightVariable::VectorPerNode: | |
1962 |
4/8✓ Branch 1 taken 3755 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3755 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3755 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3755 times.
✗ Branch 11 not taken.
|
3755 | name = "vector per node: 1 "+name+" "+name+".*****.vct\n"; |
1963 |
1/2✓ Branch 2 taken 3755 times.
✗ Branch 3 not taken.
|
3755 | fprintf( pFile, "%s", name.c_str()); |
1964 | 3755 | break; | |
1965 | ✗ | case EnsightVariable::Unknown: | |
1966 | ✗ | break; | |
1967 | // Default case should appear with a warning at compile time instead of an error in runtime | ||
1968 | // (that's truly the point of using enums as switch cases) | ||
1969 | // default: | ||
1970 | // FEL_ERROR("It is not a valid type of variable for Ensight."); | ||
1971 | } | ||
1972 | } | ||
1973 | 3112 | } | |
1974 | |||
1975 | /***********************************************************************************/ | ||
1976 | /***********************************************************************************/ | ||
1977 | |||
1978 | ✗ | void EnsightCase::case_variable_by_variable(FILE* pFile, int iVar) | |
1979 | { | ||
1980 | ✗ | std::string name; | |
1981 | ✗ | fprintf( pFile, "VARIABLE\n"); | |
1982 | ✗ | name = m_var[iVar].description(); | |
1983 | ✗ | switch( m_var[iVar].type() ) { | |
1984 | ✗ | case EnsightVariable::ScalarPerNode: | |
1985 | ✗ | name = "scalar per node: 1 "+name+" "+name+".*****.scl\n"; | |
1986 | ✗ | fprintf( pFile, "%s", name.c_str()); | |
1987 | ✗ | break; | |
1988 | ✗ | case EnsightVariable::VectorPerNode: | |
1989 | ✗ | name = "vector per node: 1 "+name+" "+name+".*****.vct\n"; | |
1990 | ✗ | fprintf( pFile, "%s", name.c_str()); | |
1991 | ✗ | break; | |
1992 | ✗ | case EnsightVariable::Unknown: | |
1993 | ✗ | break; | |
1994 | // default: | ||
1995 | // FEL_ERROR("It is not a valid type of variable for Ensight."); | ||
1996 | } | ||
1997 | } | ||
1998 | |||
1999 | /***********************************************************************************/ | ||
2000 | /***********************************************************************************/ | ||
2001 | |||
2002 | 460 | void EnsightCase::case_geometricVec(FILE* pFile) | |
2003 | { | ||
2004 | 460 | std::string name; | |
2005 |
2/2✓ Branch 0 taken 828 times.
✓ Branch 1 taken 460 times.
|
1288 | for (int i=0 ; i<m_domainDim ; i++) { |
2006 |
2/4✓ Branch 1 taken 828 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 828 times.
✗ Branch 5 not taken.
|
828 | name = "tangentVector" + std::to_string(i+1); |
2007 |
4/8✓ Branch 1 taken 828 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 828 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 828 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 828 times.
✗ Branch 11 not taken.
|
828 | name = "vector per node: 1 "+name+" "+name+".vct\n"; |
2008 |
1/2✓ Branch 2 taken 828 times.
✗ Branch 3 not taken.
|
828 | fprintf( pFile, "%s", name.c_str()); |
2009 | } | ||
2010 |
1/2✓ Branch 1 taken 460 times.
✗ Branch 2 not taken.
|
460 | name = "normalVector"; |
2011 |
4/8✓ Branch 1 taken 460 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 460 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 460 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 460 times.
✗ Branch 11 not taken.
|
460 | name = "vector per node: 1 "+name+" "+name+".vct\n"; |
2012 |
1/2✓ Branch 2 taken 460 times.
✗ Branch 3 not taken.
|
460 | fprintf( pFile, "%s", name.c_str()); |
2013 | 460 | } | |
2014 | |||
2015 | /***********************************************************************************/ | ||
2016 | /***********************************************************************************/ | ||
2017 | |||
2018 | 3112 | void EnsightCase::case_time_section(FILE* pFile) | |
2019 | { | ||
2020 | 3112 | fprintf( pFile,"TIME\n"); | |
2021 | 3112 | fprintf( pFile, "time set: %d\n", 1); | |
2022 | 3112 | fprintf( pFile,"number of steps: %d \n", m_time[0].nbSteps()); | |
2023 | 3112 | fprintf( pFile, "filename start number: %d\n", m_time[0].fileNameStartNumber()); | |
2024 | 3112 | fprintf( pFile, "filename increment: %d\n", m_time[0].fileNameIncrement()); | |
2025 | 3112 | fprintf( pFile, "time values:\n"); | |
2026 | |||
2027 | 3112 | int count=0; | |
2028 | |||
2029 |
2/2✓ Branch 2 taken 155484 times.
✓ Branch 3 taken 3112 times.
|
158596 | for (int i=0; i < m_time[0].nbSteps(); ++i) { |
2030 | 155484 | fprintf( pFile, "%12.5e",m_time[0].timeValue(i)); | |
2031 | 155484 | ++count; | |
2032 |
2/2✓ Branch 0 taken 24638 times.
✓ Branch 1 taken 130846 times.
|
155484 | if ( count == 6) { |
2033 | 24638 | fprintf( pFile, "\n" ); | |
2034 | 24638 | count=0; | |
2035 | } | ||
2036 | } | ||
2037 | 3112 | } | |
2038 | |||
2039 | /***********************************************************************************/ | ||
2040 | /***********************************************************************************/ | ||
2041 | |||
2042 | 3112 | void EnsightCase::postProcess(const std::string& outputDirectory, | |
2043 | const std::string& nameCase, | ||
2044 | int optionMultiCase, | ||
2045 | double& time) | ||
2046 | { | ||
2047 | 3112 | m_time[0].addTimeValue(time); | |
2048 | 3112 | writeCaseFile(outputDirectory,nameCase, optionMultiCase); | |
2049 | 3112 | const int indexTime = m_time[0].timeIndex(time); | |
2050 | |||
2051 | // Write variables. | ||
2052 |
2/2✓ Branch 1 taken 5378 times.
✓ Branch 2 taken 3112 times.
|
8490 | for (std::size_t iVar = 0; iVar < m_var.size(); iVar++) |
2053 | 5378 | m_var[iVar].write(outputDirectory, indexTime); | |
2054 | |||
2055 |
2/2✓ Branch 1 taken 5378 times.
✓ Branch 2 taken 3112 times.
|
8490 | for (std::size_t iVar = 0; iVar < m_var.size(); iVar++) { |
2056 | 5378 | m_var[iVar].clear(); | |
2057 | } | ||
2058 | 3112 | m_var.clear(); | |
2059 | 3112 | } | |
2060 | |||
2061 | /***********************************************************************************/ | ||
2062 | /***********************************************************************************/ | ||
2063 | |||
2064 | 12 | EnsightVariable::EnsightVariable(const std::string& aType,int time_set,int file_set, | |
2065 | 12 | const std::string& aDescription, const std::string& filename): | |
2066 | 12 | m_type(Unknown), | |
2067 | 12 | m_description(aDescription), | |
2068 |
1/2✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
|
12 | m_filename(filename) |
2069 | { | ||
2070 | IGNORE_UNUSED_ARGUMENT(time_set); | ||
2071 | IGNORE_UNUSED_ARGUMENT(file_set); | ||
2072 | // if(m_verbose) std::cout << "EnsightVariable:: " << m_description << " on " << m_filename << std::endl; | ||
2073 |
2/4✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
|
12 | if(CountOccurenceChar(filename,'*')) { |
2074 |
1/2✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
|
12 | m_filename_wildcard = filename; |
2075 | } else { | ||
2076 | ✗ | m_filename_wildcard = ""; | |
2077 | ✗ | m_filename = filename; | |
2078 | } | ||
2079 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 2 taken 4 times.
|
12 | if(aType == "scalar per node") m_type = ScalarPerNode; |
2080 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 8 times.
|
12 | if(aType == "vector per node") m_type = VectorPerNode; |
2081 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(m_type == Unknown) { |
2082 | ✗ | std::ostringstream msg; | |
2083 | ✗ | msg << aType << "EnsightVariable:: Unknown type of variable"; | |
2084 | ✗ | FEL_ERROR(msg.str()) | |
2085 | } | ||
2086 | #undef DEBUGVAR | ||
2087 | #ifdef DEBUGVAR | ||
2088 | std::cout << "type: " << aType << std::endl; | ||
2089 | std::cout << "time set: " << time_set << std::endl; | ||
2090 | std::cout << "file set: " << file_set << std::endl; | ||
2091 | std::cout << "description: " << aDescription << std::endl; | ||
2092 | std::cout << "filename: " << filename << std::endl; | ||
2093 | #endif | ||
2094 | 12 | } | |
2095 | |||
2096 | /***********************************************************************************/ | ||
2097 | /***********************************************************************************/ | ||
2098 | |||
2099 | 5378 | EnsightVariable::EnsightVariable(const EnsightVariable::TypeVar& aType, const std::string& nameVariable, const double* solution, felInt aSize, bool manageMemory): | |
2100 | 5378 | m_type(aType), | |
2101 | 5378 | m_size(aSize), | |
2102 | 5378 | m_description(nameVariable), | |
2103 |
1/2✓ Branch 2 taken 5378 times.
✗ Branch 3 not taken.
|
5378 | m_filename("none"), |
2104 |
1/2✓ Branch 2 taken 5378 times.
✗ Branch 3 not taken.
|
5378 | m_filename_wildcard("none"), |
2105 | 5378 | m_solution(solution), | |
2106 | 5378 | m_manageMemory(manageMemory) | |
2107 | { | ||
2108 | |||
2109 | 5378 | } | |
2110 | |||
2111 | /***********************************************************************************/ | ||
2112 | /***********************************************************************************/ | ||
2113 | |||
2114 | ✗ | std::string EnsightVariable::variableFile() const | |
2115 | { | ||
2116 | ✗ | if(m_filename_wildcard!="") { | |
2117 | ✗ | std::ostringstream msg; | |
2118 | ✗ | msg << "Variable file name contains wildcard characters " << m_filename_wildcard | |
2119 | ✗ | << "Use EnsightVariable::variableFile(int i) to specify the time step"; | |
2120 | ✗ | FEL_ERROR(msg.str()) | |
2121 | } | ||
2122 | ✗ | return m_filename; | |
2123 | } | ||
2124 | |||
2125 | /***********************************************************************************/ | ||
2126 | /***********************************************************************************/ | ||
2127 | |||
2128 | 5378 | std::string EnsightVariable::variableFileOutput(const std::string& outputDirectory, int istep) | |
2129 | { | ||
2130 |
1/2✓ Branch 1 taken 5378 times.
✗ Branch 2 not taken.
|
5378 | const std::string FileRootName = outputDirectory; |
2131 |
5/10✓ Branch 1 taken 5378 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5378 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5378 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 5378 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 5378 times.
✗ Branch 14 not taken.
|
10756 | const std::string fileName = FileRootName + "/" + m_description + "." + wildCard(istep); |
2132 | 10756 | return fileName; | |
2133 | 5378 | } | |
2134 | |||
2135 | /***********************************************************************************/ | ||
2136 | /***********************************************************************************/ | ||
2137 | |||
2138 | 24 | std::string EnsightVariable::variableFileInput(int istep) | |
2139 | { | ||
2140 |
1/2✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
|
24 | const std::string string_step = std::to_string(istep); |
2141 |
1/2✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
|
24 | const std::string FileRootName = m_filename.substr( 0, m_filename.find_first_of( '.' ) ); |
2142 |
1/2✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
|
24 | const std::string FileExt = m_filename.substr( m_filename.find_last_of( '.' ) +1); |
2143 |
6/12✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 24 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 24 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 24 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 24 times.
✗ Branch 17 not taken.
|
48 | const std::string fileName = FileRootName + "." + wildCard(istep) + string_step + "." + FileExt; |
2144 | 48 | return fileName; | |
2145 | 24 | } | |
2146 | |||
2147 | /***********************************************************************************/ | ||
2148 | /***********************************************************************************/ | ||
2149 | |||
2150 | 5378 | std::string EnsightVariable::description() const | |
2151 | { | ||
2152 | 5378 | return m_description; | |
2153 | } | ||
2154 | |||
2155 | /***********************************************************************************/ | ||
2156 | /***********************************************************************************/ | ||
2157 | |||
2158 | 5402 | std::string EnsightVariable::wildCard(int indexTime) | |
2159 | { | ||
2160 |
2/2✓ Branch 0 taken 247 times.
✓ Branch 1 taken 5155 times.
|
5402 | if (indexTime == 0) |
2161 |
1/2✓ Branch 2 taken 247 times.
✗ Branch 3 not taken.
|
247 | return "0000"; |
2162 |
2/2✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 3919 times.
|
5155 | else if (indexTime < 10) |
2163 |
1/2✓ Branch 2 taken 1236 times.
✗ Branch 3 not taken.
|
1236 | return "0000"; |
2164 |
2/2✓ Branch 0 taken 3017 times.
✓ Branch 1 taken 902 times.
|
3919 | else if (indexTime < 100) |
2165 |
1/2✓ Branch 2 taken 3017 times.
✗ Branch 3 not taken.
|
3017 | return "000"; |
2166 |
1/2✓ Branch 0 taken 902 times.
✗ Branch 1 not taken.
|
902 | else if (indexTime < 1000) |
2167 |
1/2✓ Branch 2 taken 902 times.
✗ Branch 3 not taken.
|
902 | return "00"; |
2168 | ✗ | else if (indexTime < 10000) | |
2169 | ✗ | return "0"; | |
2170 | else | ||
2171 | ✗ | return ""; | |
2172 | } | ||
2173 | |||
2174 | /***********************************************************************************/ | ||
2175 | /***********************************************************************************/ | ||
2176 | |||
2177 | 5378 | void EnsightVariable::write(const std::string& outputDirectory, int indexTime) | |
2178 | { | ||
2179 |
2/4✓ Branch 0 taken 1623 times.
✓ Branch 1 taken 3755 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
5378 | switch (m_type) { |
2180 | 1623 | case ScalarPerNode: | |
2181 |
1/2✓ Branch 1 taken 1623 times.
✗ Branch 2 not taken.
|
1623 | if(FelisceParam::instance().outputFileFormat == ENSIGHT6) |
2182 | 1623 | writeScalarEnsight6(outputDirectory, indexTime); | |
2183 | ✗ | else if(FelisceParam::instance().outputFileFormat == ENSIGHTGOLD) | |
2184 | ✗ | writeScalarEnsightGold(outputDirectory, indexTime); | |
2185 | ✗ | else if(FelisceParam::instance().outputFileFormat == ENSIGHT6BIN) | |
2186 | ✗ | writeScalarEnsight6Bin(outputDirectory, indexTime); | |
2187 | else | ||
2188 | ✗ | FEL_ERROR("Unknown file format"); | |
2189 | 1623 | break; | |
2190 | 3755 | case VectorPerNode : | |
2191 |
1/2✓ Branch 1 taken 3755 times.
✗ Branch 2 not taken.
|
3755 | if(FelisceParam::instance().outputFileFormat == ENSIGHT6) |
2192 | 3755 | writeVectorEnsight6(outputDirectory, indexTime); | |
2193 | ✗ | else if(FelisceParam::instance().outputFileFormat == ENSIGHTGOLD) | |
2194 | ✗ | writeVectorEnsightGold(outputDirectory, indexTime); | |
2195 | ✗ | else if(FelisceParam::instance().outputFileFormat == ENSIGHT6BIN) | |
2196 | ✗ | writeVectorEnsight6Bin(outputDirectory, indexTime); | |
2197 | else | ||
2198 | ✗ | FEL_ERROR("Unknown file format"); | |
2199 | 3755 | break; | |
2200 | ✗ | case Unknown: | |
2201 | ✗ | FEL_ERROR("Impossible to write this type of variable at the moment."); | |
2202 | } | ||
2203 | 5378 | } | |
2204 | |||
2205 | /***********************************************************************************/ | ||
2206 | /***********************************************************************************/ | ||
2207 | |||
2208 | 1623 | void EnsightVariable::writeScalarEnsight6(const std::string& outputDirectory, int indexTime) | |
2209 | { | ||
2210 |
4/8✓ Branch 1 taken 1623 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1623 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1623 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1623 times.
✗ Branch 11 not taken.
|
3246 | const std::string fileName = variableFileOutput(outputDirectory, indexTime) + std::to_string(indexTime) + ".scl"; |
2211 | FILE * pFile; | ||
2212 |
1/2✓ Branch 2 taken 1623 times.
✗ Branch 3 not taken.
|
1623 | pFile = fopen (fileName.c_str(),"w"); |
2213 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1623 times.
|
1623 | if (pFile==nullptr) { |
2214 | ✗ | FEL_ERROR("Impossible to write "+fileName+" scalar ensight solution"); | |
2215 | } | ||
2216 | |||
2217 | 1623 | int count=0; | |
2218 |
1/2✓ Branch 1 taken 1623 times.
✗ Branch 2 not taken.
|
1623 | fprintf( pFile, "Scalar per node\n"); |
2219 |
2/2✓ Branch 0 taken 3259172 times.
✓ Branch 1 taken 1623 times.
|
3260795 | for (felInt i=0; i < m_size; ++i) { |
2220 |
1/2✓ Branch 1 taken 3259172 times.
✗ Branch 2 not taken.
|
3259172 | fprintf(pFile,"%12.5e", m_solution[i] ); |
2221 | 3259172 | ++count; | |
2222 |
2/2✓ Branch 0 taken 542764 times.
✓ Branch 1 taken 2716408 times.
|
3259172 | if ( count == 6 ) { |
2223 |
1/2✓ Branch 1 taken 542764 times.
✗ Branch 2 not taken.
|
542764 | fprintf(pFile, "\n" ); |
2224 | 542764 | count=0; | |
2225 | } | ||
2226 | } | ||
2227 |
1/2✓ Branch 1 taken 1623 times.
✗ Branch 2 not taken.
|
1623 | fprintf( pFile, "\n" ); |
2228 |
1/2✓ Branch 1 taken 1623 times.
✗ Branch 2 not taken.
|
1623 | fclose( pFile ); |
2229 | 1623 | } | |
2230 | |||
2231 | /***********************************************************************************/ | ||
2232 | /***********************************************************************************/ | ||
2233 | |||
2234 | ✗ | void EnsightVariable::writeScalarEnsight6Bin(const std::string& outputDirectory, int indexTime) | |
2235 | { | ||
2236 | ✗ | const std::string fileName = variableFileOutput(outputDirectory, indexTime) + std::to_string(indexTime) + ".scl"; | |
2237 | FILE * pFile; | ||
2238 | ✗ | pFile = fopen (fileName.c_str(),"w"); | |
2239 | ✗ | if (pFile==nullptr) { | |
2240 | ✗ | FEL_ERROR("Impossible to write "+fileName+" scalar ensight solution"); | |
2241 | } | ||
2242 | |||
2243 | char buffer[80]; | ||
2244 | ✗ | local_strncpy(buffer, "Scalar per node",80); | |
2245 | ✗ | fwrite(buffer, sizeof(char), 80, pFile); | |
2246 | ✗ | float *scalar = new float[m_size]; | |
2247 | ✗ | for(int i=0; i< m_size; i++) | |
2248 | ✗ | scalar[i] = static_cast<float>(m_solution[i]); | |
2249 | |||
2250 | ✗ | fwrite(scalar,sizeof(float),m_size,pFile); | |
2251 | ✗ | fclose( pFile ); | |
2252 | ✗ | delete[] scalar; | |
2253 | } | ||
2254 | |||
2255 | /***********************************************************************************/ | ||
2256 | /***********************************************************************************/ | ||
2257 | |||
2258 | ✗ | void EnsightVariable::writeScalarEnsightGold(const std::string& outputDirectory, int indexTime) | |
2259 | { | ||
2260 | ✗ | const std::string fileName = variableFileOutput(outputDirectory, indexTime) + std::to_string(indexTime) + ".scl"; | |
2261 | FILE * pFile; | ||
2262 | ✗ | pFile = fopen (fileName.c_str(),"w"); | |
2263 | ✗ | if (pFile==nullptr) { | |
2264 | ✗ | FEL_ERROR("Impossible to write "+fileName+" scalar ensight solution"); | |
2265 | } | ||
2266 | |||
2267 | ✗ | int label=0; | |
2268 | ✗ | fprintf( pFile, "Ensight Gold scalar per node\n"); | |
2269 | |||
2270 | // loop over references | ||
2271 | ✗ | for (auto refIt = m_ref2list.begin(); refIt != m_ref2list.end(); ++refIt) { | |
2272 | ✗ | label = refIt->first; | |
2273 | ✗ | fprintf(pFile, "part\n"); | |
2274 | ✗ | fprintf(pFile, "%10d\n", label + 1); | |
2275 | ✗ | fprintf(pFile, "coordinates\n"); | |
2276 | |||
2277 | ✗ | for(std::size_t inode=0; inode < refIt->second.size(); ++inode) { | |
2278 | ✗ | fprintf(pFile,"%12.5e\n", m_solution[refIt->second[inode]]); | |
2279 | } | ||
2280 | } | ||
2281 | |||
2282 | ✗ | fclose( pFile ); | |
2283 | } | ||
2284 | |||
2285 | /***********************************************************************************/ | ||
2286 | /***********************************************************************************/ | ||
2287 | |||
2288 | 3755 | void EnsightVariable::writeVectorEnsight6(const std::string& outputDirectory, int indexTime) | |
2289 | { | ||
2290 |
4/8✓ Branch 1 taken 3755 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3755 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3755 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3755 times.
✗ Branch 11 not taken.
|
7510 | const std::string fileName = variableFileOutput(outputDirectory, indexTime) + std::to_string(indexTime) +".vct"; |
2291 | FILE * pFile; | ||
2292 |
1/2✓ Branch 2 taken 3755 times.
✗ Branch 3 not taken.
|
3755 | pFile = fopen (fileName.c_str(),"w"); |
2293 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3755 times.
|
3755 | if (pFile==nullptr) { |
2294 | ✗ | FEL_ERROR("Impossible to write "+fileName+" vectorial ensight solution"); | |
2295 | } | ||
2296 | 3755 | int count=0; | |
2297 | 3755 | int nDimensions = 3; | |
2298 |
1/2✓ Branch 1 taken 3755 times.
✗ Branch 2 not taken.
|
3755 | fprintf( pFile, "Vector per node\n"); |
2299 | // [u_x_1, u_y_1, u_z_1,u_x_2, u_y_2, u_z_2, ..., u_x_dim, u_y_dim, u_z_dim ] | ||
2300 |
2/2✓ Branch 0 taken 4499478 times.
✓ Branch 1 taken 3755 times.
|
4503233 | for ( felInt i=0; i < m_size; ++i ) { |
2301 |
2/2✓ Branch 0 taken 13498434 times.
✓ Branch 1 taken 4499478 times.
|
17997912 | for ( int j=0; j < nDimensions; ++j ) { |
2302 | //std::cout << m_solution[ i*nDimensions+j ] << std::endl; | ||
2303 |
1/2✓ Branch 1 taken 13498434 times.
✗ Branch 2 not taken.
|
13498434 | fprintf(pFile,"%12.5e", (float)m_solution[ i*nDimensions+j ] ); |
2304 | 13498434 | ++count; | |
2305 | |||
2306 |
2/2✓ Branch 0 taken 2248815 times.
✓ Branch 1 taken 11249619 times.
|
13498434 | if ( count == 6 ) { |
2307 |
1/2✓ Branch 1 taken 2248815 times.
✗ Branch 2 not taken.
|
2248815 | fprintf(pFile, "\n" ); |
2308 | 2248815 | count=0; | |
2309 | } | ||
2310 | } | ||
2311 | } | ||
2312 |
1/2✓ Branch 1 taken 3755 times.
✗ Branch 2 not taken.
|
3755 | fprintf( pFile, "\n" ); |
2313 |
1/2✓ Branch 1 taken 3755 times.
✗ Branch 2 not taken.
|
3755 | fclose( pFile ); |
2314 | 3755 | } | |
2315 | |||
2316 | /***********************************************************************************/ | ||
2317 | /***********************************************************************************/ | ||
2318 | |||
2319 | ✗ | void EnsightVariable::writeVectorEnsight6Bin(const std::string& outputDirectory, int indexTime) | |
2320 | { | ||
2321 | ✗ | const std::string fileName = variableFileOutput(outputDirectory, indexTime) + std::to_string(indexTime) +".vct"; | |
2322 | FILE * pFile; | ||
2323 | ✗ | pFile = fopen (fileName.c_str(),"w"); | |
2324 | ✗ | if (pFile==nullptr) | |
2325 | ✗ | FEL_ERROR("Impossible to write "+fileName+" vectorial ensight solution"); | |
2326 | |||
2327 | char buffer[80]; | ||
2328 | ✗ | local_strncpy(buffer, "Vector per node\n",80); | |
2329 | ✗ | fwrite(buffer, sizeof(char), 80, pFile); | |
2330 | ✗ | float* vector = new float[3*m_size]; | |
2331 | ✗ | for(int i=0; i< 3*m_size; ++i) | |
2332 | ✗ | vector[i] = static_cast<float>(m_solution[i]); | |
2333 | ✗ | fwrite(vector,sizeof(float),3*m_size,pFile); | |
2334 | ✗ | fclose( pFile ); | |
2335 | ✗ | delete [] vector; | |
2336 | } | ||
2337 | |||
2338 | /***********************************************************************************/ | ||
2339 | /***********************************************************************************/ | ||
2340 | |||
2341 | ✗ | void EnsightVariable::writeVectorEnsightGold(const std::string& outputDirectory, int indexTime) | |
2342 | { | ||
2343 | ✗ | const std::string fileName = variableFileOutput(outputDirectory, indexTime) + std::to_string(indexTime) +".vct"; | |
2344 | FILE * pFile; | ||
2345 | ✗ | pFile = fopen (fileName.c_str(),"w"); | |
2346 | ✗ | if(pFile==nullptr) | |
2347 | ✗ | FEL_ERROR("Impossible to write "+fileName+" vectorial ensight solution"); | |
2348 | |||
2349 | ✗ | std::size_t nDim = 3; | |
2350 | ✗ | int label = 0; | |
2351 | ✗ | fprintf(pFile, "Ensight Gold vector per node\n"); | |
2352 | |||
2353 | // loop over references | ||
2354 | ✗ | for (auto refIt = m_ref2list.begin(); refIt != m_ref2list.end(); ++refIt) { | |
2355 | ✗ | label = refIt->first; | |
2356 | ✗ | fprintf(pFile, "part\n"); | |
2357 | ✗ | fprintf(pFile, "%10d\n", label + 1); | |
2358 | ✗ | fprintf(pFile, "coordinates\n"); | |
2359 | |||
2360 | // [u_x_1, u_x_2, u_x_3, ..., u_y_1, u_y_2, u_y_3, ..., u_z_1, u_z_2, u_z_3, ...] | ||
2361 | ✗ | for(std::size_t idim=0; idim<nDim; ++idim) | |
2362 | ✗ | for(std::size_t inode=0; inode < refIt->second.size(); ++inode) | |
2363 | ✗ | fprintf(pFile, "%12.5e\n", m_solution[refIt->second[inode]*nDim + idim]); | |
2364 | } | ||
2365 | |||
2366 | ✗ | fclose(pFile); | |
2367 | } | ||
2368 | |||
2369 | /***********************************************************************************/ | ||
2370 | /***********************************************************************************/ | ||
2371 | |||
2372 | 1003 | EnsightTimeBis::EnsightTimeBis(int time_set,int num_steps,int filename_start_number,int filename_increment): | |
2373 | 1003 | m_num_steps(num_steps), | |
2374 | 1003 | m_filename_start_number(filename_start_number), | |
2375 | 1003 | m_filename_increment(filename_increment) | |
2376 | { | ||
2377 | IGNORE_UNUSED_ARGUMENT(time_set); | ||
2378 |
1/2✓ Branch 1 taken 1003 times.
✗ Branch 2 not taken.
|
1003 | m_time_values.resize(m_num_steps); |
2379 | 1003 | } | |
2380 | |||
2381 | /***********************************************************************************/ | ||
2382 | /***********************************************************************************/ | ||
2383 | |||
2384 | 3136 | int EnsightTimeBis::timeIndex(double time) const | |
2385 | { | ||
2386 |
1/2✓ Branch 0 taken 155566 times.
✗ Branch 1 not taken.
|
155566 | for(int i=0; i<m_num_steps; i++) { |
2387 |
2/2✓ Branch 2 taken 3136 times.
✓ Branch 3 taken 152430 times.
|
155566 | if( std::fabs(time - m_time_values[i]) <= 150*DBL_EPSILON*( std::fabs(time)+std::fabs(m_time_values[i]) )) { |
2388 | 3136 | return (i+m_filename_start_number); | |
2389 | } | ||
2390 | } | ||
2391 | |||
2392 | ✗ | const std::string error_message = "EnsightTime::timeIndex : time " + std::to_string(time) + " is not in the time set"; | |
2393 | ✗ | FEL_ERROR(error_message) | |
2394 | ✗ | return 0; | |
2395 | } | ||
2396 | |||
2397 | /***********************************************************************************/ | ||
2398 | /***********************************************************************************/ | ||
2399 | |||
2400 | 3112 | void EnsightTimeBis::addTimeValue(double& time) | |
2401 | { | ||
2402 | 3112 | m_time_values.push_back(time); | |
2403 | 3112 | m_num_steps++; | |
2404 | 3112 | } | |
2405 | |||
2406 | /***********************************************************************************/ | ||
2407 | /***********************************************************************************/ | ||
2408 | |||
2409 | 713 | std::string Ensight::getKeyword(const ElementType eltType) | |
2410 | { | ||
2411 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 687 times.
|
713 | if (eltType == GeometricMeshRegion::Prism9 ) { // Prism9 |
2412 |
1/2✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
|
26 | return "penta6"; |
2413 |
2/2✓ Branch 0 taken 75 times.
✓ Branch 1 taken 612 times.
|
687 | } else if ( eltType == GeometricMeshRegion::Quad6 ) { // Quad6 |
2414 |
1/2✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
|
75 | return "quad4"; |
2415 | } else { | ||
2416 | 612 | return m_eltFelNameToEns6Pair[GeometricMeshRegion::eltEnumToFelNameGeoEle[eltType].first].second; | |
2417 | } | ||
2418 | } | ||
2419 | |||
2420 | /***********************************************************************************/ | ||
2421 | /***********************************************************************************/ | ||
2422 | |||
2423 | 713 | void Ensight::prepareElemIndexes(std::vector<std::vector<felInt>>& elem, const ElementType eltType) | |
2424 | { | ||
2425 | 713 | const int nVpEl = getNumberPointsElement(eltType); | |
2426 |
4/4✓ Branch 0 taken 687 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 612 times.
|
713 | const std::size_t number_of_sub_elem = (eltType == GeometricMeshRegion::Prism9 || eltType == GeometricMeshRegion::Quad6) ? 2 : 1; |
2427 |
2/2✓ Branch 1 taken 55 times.
✓ Branch 2 taken 658 times.
|
713 | if (elem.size() != number_of_sub_elem) |
2428 | 55 | elem.resize(number_of_sub_elem); | |
2429 |
2/2✓ Branch 0 taken 814 times.
✓ Branch 1 taken 713 times.
|
1527 | for (std::size_t i = 0; i < number_of_sub_elem; ++i) |
2430 |
1/2✓ Branch 2 taken 814 times.
✗ Branch 3 not taken.
|
814 | elem[i].resize(nVpEl, 0); |
2431 | 713 | } | |
2432 | |||
2433 | /***********************************************************************************/ | ||
2434 | /***********************************************************************************/ | ||
2435 | |||
2436 | 608094 | void Ensight::getElemIndexes(GeometricMeshRegion& mesh, const ElementType eltType, const felInt iel, std::vector<std::vector<felInt>>& elem, const felInt startindex, const bool incr_vert_id) | |
2437 | { | ||
2438 |
2/2✓ Branch 0 taken 3323 times.
✓ Branch 1 taken 604771 times.
|
608094 | if (eltType == GeometricMeshRegion::Prism9 ) { // Prism9 |
2439 |
1/2✓ Branch 2 taken 3323 times.
✗ Branch 3 not taken.
|
3323 | std::vector<felInt> aux_elem(9, 0); |
2440 |
1/2✓ Branch 1 taken 3323 times.
✗ Branch 2 not taken.
|
3323 | mesh.getOneElement(eltType, iel, aux_elem, startindex, incr_vert_id); |
2441 | 3323 | elem[0][0] = aux_elem[0]; | |
2442 | 3323 | elem[0][1] = aux_elem[1]; | |
2443 | 3323 | elem[0][2] = aux_elem[2]; | |
2444 | 3323 | elem[0][3] = aux_elem[6]; | |
2445 | 3323 | elem[0][4] = aux_elem[7]; | |
2446 | 3323 | elem[0][5] = aux_elem[8]; | |
2447 | 3323 | elem[1][0] = aux_elem[6]; | |
2448 | 3323 | elem[1][1] = aux_elem[7]; | |
2449 | 3323 | elem[1][2] = aux_elem[8]; | |
2450 | 3323 | elem[1][3] = aux_elem[3]; | |
2451 | 3323 | elem[1][4] = aux_elem[4]; | |
2452 | 3323 | elem[1][5] = aux_elem[5]; | |
2453 |
2/2✓ Branch 1 taken 390 times.
✓ Branch 2 taken 604381 times.
|
608094 | } else if ( eltType == GeometricMeshRegion::Quad6 ) { // Quad6 |
2454 |
1/2✓ Branch 2 taken 390 times.
✗ Branch 3 not taken.
|
390 | std::vector<felInt> aux_elem(6, 0); |
2455 |
1/2✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
|
390 | mesh.getOneElement(eltType, iel, aux_elem, startindex, incr_vert_id); |
2456 | 390 | elem[0][0] = aux_elem[0]; | |
2457 | 390 | elem[0][1] = aux_elem[1]; | |
2458 | 390 | elem[0][2] = aux_elem[4]; | |
2459 | 390 | elem[0][3] = aux_elem[5]; | |
2460 | 390 | elem[1][0] = aux_elem[4]; | |
2461 | 390 | elem[1][1] = aux_elem[5]; | |
2462 | 390 | elem[1][2] = aux_elem[3]; | |
2463 | 390 | elem[1][3] = aux_elem[2]; | |
2464 | 390 | } else { | |
2465 | 604381 | mesh.getOneElement(eltType, iel, elem[0], startindex, incr_vert_id); | |
2466 | } | ||
2467 | 608094 | } | |
2468 | |||
2469 | /***********************************************************************************/ | ||
2470 | /***********************************************************************************/ | ||
2471 | |||
2472 | 713 | int Ensight::getNumberPointsElement(const ElementType eltType) | |
2473 | { | ||
2474 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 687 times.
|
713 | if (eltType == GeometricMeshRegion::Prism9 ) { // Prism9 |
2475 | 26 | return 6; | |
2476 |
2/2✓ Branch 0 taken 75 times.
✓ Branch 1 taken 612 times.
|
687 | } else if ( eltType == GeometricMeshRegion::Quad6 ) { // Quad6 |
2477 | 75 | return 4; | |
2478 | } else { | ||
2479 | 612 | return GeometricMeshRegion::m_numPointsPerElt[eltType]; | |
2480 | } | ||
2481 | } | ||
2482 | |||
2483 | /***********************************************************************************/ | ||
2484 | /***********************************************************************************/ | ||
2485 | |||
2486 | 713 | felInt Ensight::getNumberOfElements(GeometricMeshRegion& mesh, const ElementType eltType, const int the_ref) | |
2487 | { | ||
2488 |
4/4✓ Branch 0 taken 687 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 612 times.
|
713 | if (eltType == GeometricMeshRegion::Prism9 || eltType == GeometricMeshRegion::Quad6 ) { // Prism9/Quad6 |
2489 | 101 | return 2 * mesh.intRefToBegEndMaps[eltType][the_ref].second; | |
2490 | } else { | ||
2491 | 612 | return mesh.intRefToBegEndMaps[eltType][the_ref].second; | |
2492 | } | ||
2493 | } | ||
2494 | |||
2495 | } | ||
2496 |