43 CmguiMeshWriteType writeType)
45 mpQuadraticMesh(&rQuadraticMesh),
50 if (p_quad_mesh ==
nullptr)
52 EXCEPTION(
"CmguiDeformedSolutionsWriter only supports use of a QuadraticMesh");
57 if (writeType == WRITE_QUADRATIC_MESH)
92 unsigned reordering[6] = {0,5,1,4,3,2};
93 for (
unsigned i=0; i<6; i++)
110 unsigned reordering[10] = {0,4,1,6,5,2,7,8,9,3};
111 for (
unsigned i=0; i<10; i++)
145 if (mpQuadraticMesh->GetNumNodes() != rDeformedPositions.size() )
147 EXCEPTION(
"The size of rDeformedPositions does not match the number of nodes in the mesh");
150 mFinalCounter = counter;
151 std::stringstream node_file_name_stringstream;
152 node_file_name_stringstream << this->mBaseName <<
"_" << counter <<
".exnode";
154 out_stream p_node_file = this->mpOutputFileHandler->OpenOutputFile(node_file_name_stringstream.str());
156 this->WriteNodeFileHeader(p_node_file);
159 for (
unsigned index=0; index<this->GetNumNodes(); index++)
161 *p_node_file <<
"Node:\t" << index+1 <<
"\t";
163 for (
unsigned i=0; i<DIM; i++)
165 *p_node_file << rDeformedPositions[index](i) <<
"\t";
167 *p_node_file <<
"\n";
169 p_node_file->close();
175 std::string field_string =
"";
176 if (fieldBaseName !=
"")
178 field_string =
" gfx read node " + fieldBaseName +
"_$i time $i\n";
181 out_stream p_script_file = this->mpOutputFileHandler->OpenOutputFile(
"LoadSolutions.com");
182 *p_script_file <<
"#\n# Cmgui script automatically generated by Chaste\n#\n";
184 if (undeformedBaseName !=
"")
186 *p_script_file <<
"gfx read node " << undeformedBaseName <<
" time -1\n";
189 *p_script_file <<
"for ($i=0; $i<=" << mFinalCounter <<
"; $i++) { \n"
190 <<
" gfx read node " << this->mBaseName <<
"_$i time $i\n"
194 if (undeformedBaseName !=
"")
196 for (
unsigned region_index=0; region_index<this->mRegionNames.size(); region_index++)
198 *p_script_file <<
"gfx read ele " << this->mRegionNames[region_index] <<
"\n";
203 *p_script_file <<
"gfx read ele " << this->mBaseName <<
"_0\n";
205 *p_script_file <<
"gfx define faces egroup "<<this->mBaseName<<
"\n";
206 *p_script_file <<
"gfx modify g_element "<<this->mBaseName<<
" lines select_on material default spectrum default selected_material default_selected;\n";
207 *p_script_file <<
"gfx cr win\n\n";
208 p_script_file->close();
213 std::string inputFileBaseName,
214 unsigned finalCounter)
219 std::vector<c_vector<double,DIM> > deformed_position(mpQuadraticMesh->GetNumNodes(), zero_vector<double>(DIM));
221 for (
unsigned i=1; i<=finalCounter; i++)
223 std::stringstream in_file_stream;
224 in_file_stream << inputDirectory <<
"/" << inputFileBaseName <<
"_" << i <<
".nodes";
226 std::ifstream ifs(in_file_stream.str().c_str());
229 EXCEPTION(
"Could not open file: " + in_file_stream.str());
234 for (
unsigned index=0; index<mpQuadraticMesh->GetNumNodes(); index++)
236 for (
unsigned j=0; j<DIM; j++)
241 EXCEPTION(
"Error occurred when reading file " << in_file_stream.str()
242 <<
". Expected " << mpQuadraticMesh->GetNumNodes() <<
" rows and "
243 << DIM <<
" columns");
245 deformed_position[index](j) = data;
252 WriteDeformationPositions(deformed_position, i);