36#include "AbstractPdeModifier.hpp"
37#include "VtkMeshWriter.hpp"
38#include "ReplicatableVector.hpp"
39#include "AveragedSourceEllipticPde.hpp"
40#include "AveragedSourceParabolicPde.hpp"
45 bool isNeumannBoundaryCondition,
49 mpBoundaryCondition(pBoundaryCondition),
50 mIsNeumannBoundaryCondition(isNeumannBoundaryCondition),
53 mOutputGradient(false),
54 mOutputSolutionAtPdeNodes(false),
66 if (mDeleteFeMesh and mpFeMesh!=
nullptr)
85 return mpBoundaryCondition;
91 return mIsNeumannBoundaryCondition;
97 mDependentVariableName = rName;
100template<
unsigned DIM>
103 return mDependentVariableName;
106template<
unsigned DIM>
113template<
unsigned DIM>
116 assert(HasAveragedSourcePde());
119 boost::static_pointer_cast<AveragedSourceEllipticPde<DIM> >(mpPde)->SetupSourceTerms(*pMesh, pCellPdeElementMap);
123 boost::static_pointer_cast<AveragedSourceParabolicPde<DIM> >(mpPde)->SetupSourceTerms(*pMesh, pCellPdeElementMap);
127template<
unsigned DIM>
133template<
unsigned DIM>
139template<
unsigned DIM>
145template<
unsigned DIM>
149 this->mOutputDirectory = outputDirectory;
151 if (mOutputSolutionAtPdeNodes)
156 mpVizPdeSolutionResultsFile = output_file_handler.
OpenOutputFile(
"results.vizpdesolution");
161template<
unsigned DIM>
164 if (mOutputSolutionAtPdeNodes)
170 assert(mpFeMesh !=
nullptr);
171 assert(mDependentVariableName !=
"");
173 for (
unsigned i=0; i<mpFeMesh->GetNumNodes(); i++)
175 (*mpVizPdeSolutionResultsFile) << i <<
" ";
176 const c_vector<double,DIM>& r_location = mpFeMesh->GetNode(i)->rGetLocation();
177 for (
unsigned k=0; k<DIM; k++)
179 (*mpVizPdeSolutionResultsFile) << r_location[k] <<
" ";
182 assert(mSolution !=
nullptr);
184 (*mpVizPdeSolutionResultsFile) << solution_repl[i] <<
" ";
187 (*mpVizPdeSolutionResultsFile) <<
"\n";
193 std::ostringstream time_string;
195 std::string results_file =
"pde_results_" + mDependentVariableName +
"_" + time_string.str();
199 std::vector<double> pde_solution;
200 for (
unsigned i=0; i<mpFeMesh->GetNumNodes(); i++)
202 pde_solution.push_back(solution_repl[i]);
205 p_vtk_mesh_writer->
AddPointData(mDependentVariableName, pde_solution);
208 delete p_vtk_mesh_writer;
213template<
unsigned DIM>
216 if (mOutputSolutionAtPdeNodes)
220 mpVizPdeSolutionResultsFile->close();
225template<
unsigned DIM>
228 return mOutputGradient;
231template<
unsigned DIM>
234 mOutputGradient = outputGradient;
237template<
unsigned DIM>
240 mOutputSolutionAtPdeNodes = outputSolutionAtPdeNodes;
243template<
unsigned DIM>
virtual void OutputSimulationModifierParameters(out_stream &rParamsFile)=0
virtual void SetupSolve(AbstractCellPopulation< DIM, DIM > &rCellPopulation, std::string outputDirectory)
virtual void UpdateAtEndOfOutputTimeStep(AbstractCellPopulation< DIM, DIM > &rCellPopulation)
void OutputSimulationModifierParameters(out_stream &rParamsFile)
virtual ~AbstractPdeModifier()
void SetOutputSolutionAtPdeNodes(bool outputSolutionAtPdeNodes)
void SetOutputGradient(bool outputGradient)
TetrahedralMesh< DIM, DIM > * GetFeMesh() const
bool IsNeumannBoundaryCondition()
boost::shared_ptr< AbstractLinearPde< DIM, DIM > > GetPde()
virtual void UpdateAtEndOfSolve(AbstractCellPopulation< DIM, DIM > &rCellPopulation)
std::string & rGetDependentVariableName()
void SetDependentVariableName(const std::string &rName)
bool HasAveragedSourcePde()
void SetUpSourceTermsForAveragedSourcePde(TetrahedralMesh< DIM, DIM > *pMesh, std::map< CellPtr, unsigned > *pCellPdeElementMap=nullptr)
AbstractPdeModifier(boost::shared_ptr< AbstractLinearPde< DIM, DIM > > pPde=NULL, boost::shared_ptr< AbstractBoundaryCondition< DIM > > pBoundaryCondition=boost::shared_ptr< AbstractBoundaryCondition< DIM > >(), bool isNeumannBoundaryCondition=true, Vec solution=nullptr)
boost::shared_ptr< AbstractBoundaryCondition< DIM > > GetBoundaryCondition()
out_stream OpenOutputFile(const std::string &rFileName, std::ios_base::openmode mode=std::ios::out|std::ios::trunc) const
static SimulationTime * Instance()
unsigned GetTimeStepsElapsed() const
void AddPointData(std::string name, std::vector< double > data)
void WriteFilesUsingMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rMesh, bool keepOriginalElementIndexing=true)