36 #include "VoltageInterpolaterOntoMechanicsMesh.hpp" 37 #include "Hdf5ToCmguiConverter.hpp" 38 #include "FineCoarseMeshPair.hpp" 39 #include "ReplicatableVector.hpp" 40 #include "HeartConfig.hpp" 41 #include "Hdf5DataReader.hpp" 43 #include "Hdf5DataWriter.hpp" 45 template<
unsigned DIM>
49 std::vector<std::string>& rVariableNames,
50 std::string directory,
51 std::string inputFileNamePrefix)
67 "voltage_mechanics_mesh",
71 std::vector<int> columns_id;
72 for (
unsigned var_index = 0; var_index < rVariableNames.size(); var_index++)
74 std::string var_name = rVariableNames[var_index];
75 columns_id.push_back( p_writer->DefineVariable(var_name,
"mV") );
79 p_writer->DefineFixedDimension( rMechanicsMesh.
GetNumNodes() );
80 p_writer->EndDefineMode();
82 assert(columns_id.size() == rVariableNames.size());
86 Vec voltage = factory.CreateVec();
87 std::vector<double> interpolated_voltages(rMechanicsMesh.
GetNumNodes());
88 Vec voltage_coarse = NULL;
90 for (
unsigned time_step=0; time_step<num_timesteps; time_step++)
92 for (
unsigned var_index = 0; var_index < rVariableNames.size(); var_index++)
94 std::string var_name = rVariableNames[var_index];
102 double interpolated_voltage = 0;
105 for (
unsigned node_index = 0; node_index<element.
GetNumNodes(); node_index++)
108 interpolated_voltage += voltage_repl[global_node_index]*mesh_pair.
rGetElementsAndWeights()[i].Weights(node_index);
111 interpolated_voltages[i] = interpolated_voltage;
114 if (voltage_coarse != NULL)
120 p_writer->PutVector(columns_id[var_index], voltage_coarse);
122 p_writer->PutUnlimitedVariable(time_step);
123 p_writer->AdvanceAlongUnlimitedDimension();
126 if (voltage_coarse != NULL)
141 "voltage_mechanics_mesh",
virtual DistributedVectorFactory * GetDistributedVectorFactory()
void SetOutputDirectory(const std::string &rOutputDirectory)
unsigned GetNodeGlobalIndex(unsigned localIndex) const
void ComputeFineElementsAndWeightsForCoarseNodes(bool safeMode)
std::vector< ElementAndWeights< DIM > > & rGetElementsAndWeights()
Element< ELEMENT_DIM, SPACE_DIM > * GetElement(unsigned index) const
virtual unsigned GetNumNodes() const
VoltageInterpolaterOntoMechanicsMesh(TetrahedralMesh< DIM, DIM > &rElectricsMesh, QuadraticMesh< DIM > &rMechanicsMesh, std::vector< std::string > &rVariableNames, std::string directory, std::string inputFileNamePrefix)
void GetVariableOverNodes(Vec data, const std::string &rVariableName, unsigned timestep=0)
unsigned GetNumNodes() const
std::vector< double > GetUnlimitedDimensionValues()
void SetUpBoxesOnFineMesh(double boxWidth=-1)
std::string GetOutputDirectory() const
static HeartConfig * Instance()
void DefineUnlimitedDimension(const std::string &rVariableName, const std::string &rVariableUnits, unsigned estimatedLength=1)