35 #ifndef ABSTRACTPERELEMENTWRITER_HPP_
36 #define ABSTRACTPERELEMENTWRITER_HPP_
38 #include "AbstractTetrahedralMesh.hpp"
40 #include "OutputFileHandler.hpp"
41 #include "Version.hpp"
48 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned DATA_SIZE>
75 unsigned localElementIndex,
76 c_vector<double, DATA_SIZE>& rData)=0;
90 mpMasterFile->write((
char*)&rData[0], DATA_SIZE*
sizeof(
double));
94 for (
unsigned i=0; i<DATA_SIZE; i++)
96 (*mpMasterFile) << rData[i] <<
"\t";
98 (*mpMasterFile)<<
"\n";
153 c_vector<double, DATA_SIZE> data;
158 status.MPI_ERROR = MPI_SUCCESS;
172 unsigned local_element_index=0u;
175 for (
unsigned global_element_index=0; global_element_index<
mpMesh->GetNumElements(); global_element_index++)
177 if (
mpMesh->CalculateDesignatedOwnershipOfElement(global_element_index))
181 while (&(*iter) != p_elem)
184 local_element_index++;
185 assert(iter !=
mpMesh->GetElementIteratorEnd());
188 Visit(p_elem, local_element_index, data);
193 MPI_Recv(&data[0], DATA_SIZE, MPI_DOUBLE, MPI_ANY_SOURCE, global_element_index, PETSC_COMM_WORLD, &status);
203 unsigned previous_index = 0u;
204 unsigned local_index = 0u;
206 iter !=
mpMesh->GetElementIteratorEnd();
207 ++iter, local_index++)
209 unsigned element_index = iter->GetIndex();
211 if (previous_index>0u)
213 assert(element_index > previous_index);
215 previous_index = element_index;
216 if (
mpMesh->CalculateDesignatedOwnershipOfElement(element_index))
219 Visit(&(*iter), local_index, data);
221 MPI_Ssend(&data[0], DATA_SIZE, MPI_DOUBLE, 0, element_index, PETSC_COMM_WORLD);
AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > * mpMesh
virtual ~AbstractPerElementWriter()
virtual void PreWriteCalculations(OutputFileHandler &rOutputDirectory)
virtual void WriteElementOnMaster(const c_vector< double, DATA_SIZE > &rData)
virtual void WriteHeaderOnMaster()
void SetWriteFileAsBinary(bool binary=true)
out_stream OpenOutputFile(const std::string &rFileName, std::ios_base::openmode mode=std::ios::out|std::ios::trunc) const
virtual void Visit(Element< ELEMENT_DIM, SPACE_DIM > *pElement, unsigned localElementIndex, c_vector< double, DATA_SIZE > &rData)=0
void WriteData(OutputFileHandler &rHandler, const std::string &rFileName)
static std::string GetProvenanceString()
AbstractPerElementWriter(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)