36 #include "CmguiDeformedSolutionsWriter.hpp" 39 template<
unsigned DIM>
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++)
125 template<
unsigned DIM>
128 std::string saved_base_name = this->
mBaseName;
141 template<
unsigned DIM>
147 EXCEPTION(
"The size of rDeformedPositions does not match the number of nodes in the mesh");
151 std::stringstream node_file_name_stringstream;
152 node_file_name_stringstream << this->
mBaseName <<
"_" << counter <<
".exnode";
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();
172 template<
unsigned DIM>
175 std::string field_string =
"";
176 if (fieldBaseName !=
"")
178 field_string =
" gfx read node " + fieldBaseName +
"_$i time $i\n";
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();
211 template<
unsigned DIM>
213 std::string inputFileBaseName,
214 unsigned finalCounter)
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());
236 for (
unsigned j=0; j<DIM; j++)
241 EXCEPTION(
"Error occurred when reading file " << in_file_stream.str()
243 << DIM <<
" columns");
245 deformed_position[index](j) = data;
std::string mAdditionalFieldHeader
#define EXCEPTION(message)
OutputFileHandler * mpOutputFileHandler
virtual unsigned GetNumNodes() const
std::string mCoordinatesFileHeader
std::vector< std::string > mRegionNames
out_stream OpenOutputFile(const std::string &rFileName, std::ios_base::openmode mode=std::ios::out|std::ios::trunc) const
virtual unsigned GetNumVertices() const
std::string mElementFileHeader
unsigned mNumNodesPerElement
std::vector< unsigned > mReordering
virtual void WriteFilesUsingMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rMesh, bool keepOriginalElementIndexing=true)
void WriteNodeFileHeader(out_stream &rpNodeFile)