39 m_timeWriter (nullptr),
40 m_nbIterPostProcess (1),
41 m_activationTimeData ({}),
42 m_activationNotYetSeen({}),
43 m_activationSeen ({}),
47 m_activatedVolume ({}),
53 "Cannot create post processing unit from nullptr solver link"
56 m_problem = solver->getCardiacProblem();
57 m_geom = m_problem->getGeometry();
58 m_timeWriter = solver->getTimeWriter();
61 setupWithParameters(m_problem->getParameters());
63 initializeActivationMap();
70 CEPS_SAYS(
"Fraction of activated tissue for activation data set #" << i <<
": "
88 solution ->getLocalData();
89 prevSolution ->getLocalData();
94 m_APD ->getLocalData();
113 if ((*solution)[dofId] > threshold)
115 tmpSetOfSeens.insert(dofId);
116 (*m_activationTimes)[dofId] = t;
117 (*m_activated )[dofId] = 1.;
127 if (((*solution)[dofId]>minV4Peak) and (*solution)[dofId] < (*prevSolution)[dofId])
130 (*m_peakValues)[dofId] = (*solution)[dofId];
131 (*m_peakTimes) [dofId] = t;
134 if ((*solution)[dofId]<threshold)
136 (*m_activated)[dofId] = 0.;
143 auto testPercent = [&] (
double x,
double perc) {
144 double thres = ((*m_peakValues)[dofId]-threshold)*(1-perc)+threshold;
149 and testPercent((*solution)[dofId],0.5))
151 (*m_APD50)[dofId] = t;
157 and testPercent((*solution)[dofId],apdpctg))
173 for (
auto dofId: tmpSetOfSeens)
180 solution ->releaseLocalData();
181 prevSolution ->releaseLocalData();
186 m_APD ->releaseLocalData();
212 namesAct .push_back(
"Activation time (" + u->
getName() +
")");
213 namesPV .push_back(
"Peak value (" + u->
getName() +
")");
214 namesPT .push_back(
"Peak time (" + u->
getName() +
")");
215 namesAPD50.push_back(
"APD50 (" + u->
getName() +
")");
216 namesAPD .push_back(
"APD (" + u->
getName() +
")");
261 if (p->
hasKey(
"post processing perdiod"))
264 if (p->
hasKey(
"activation time data"))
269 std::stringstream ss(opts);
271 "activation time data: unable to read unknown id from string " + opts
274 "unable to read activation time data (3 real numbers) from input string " + opts
277 "activation time data : cannot find unknown with ID " +
ceps::toString(uId)
298 m_APD50 = sd->newDofHaloVector();
299 m_APD = sd->newDofHaloVector();
307 m_APD ->fill(std::nan(
""));
320 if (dof->getUnknown()==u)
321 indices.insert(dof->getGlobalIndex());
328 std::stringstream ss;
329 ss <<
"relative activated volume for activation time data set #" << i;
336 auto fe = ceps::runtimeCast<FiniteElements*>(sd);
337 DHVecPtr tissue = sd->newDofHaloVector();
340 CepsBool allTissue = tAttrs.empty() or (tAttrs.size()==1 and tAttrs.contains(-1));
343 tissue->getLocalData();
344 for (
auto toParse: {dofs,hdofs})
345 for (
auto dof: toParse)
346 if (dof->hasOneOfAttributes(tAttrs) or allTissue)
347 (*tissue)[dof->getGlobalIndex()] = 1.;
348 tissue->releaseLocalData();
360 for (
auto aset : arrays)
361 nbSeen += aset.second.size();
#define CEPS_SAYS(message)
Writes a message in the debug log and in the terminal (stdio).
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
std::basic_string< CepsChar > CepsString
C++ format string.
CepsIndex CepsUnknownIndex
For unknowns.
std::map< _Key, _Tp, _Compare, _Alloc > CepsMap
C++ map.
std::set< _Type, _Compare, _Alloc > CepsSet
C++ set.
std::vector< _Type, _Alloc > CepsVector
C++ vector.
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
float CepsReal
Need single precision floating point.
CepsArray3< CepsReal > CepsReal3D
Three real scalars, used like this for compatibility in polynomials.
int32_t CepsInt
Need 32 bit integer.
std::shared_ptr< DistributedHaloVector > DHVecPtr
Typedef for pointer on Distributed Halo CepsVector.
DistributedInfos< DegreeOfFreedom * > * getDistributedDofs() const
Get the stored Degree Of Freedom repartition.
CepsOutputFormat getOutputFormat() const
Tells if output is binary or ascii.
CepsString getOutputFileBase() const
Output file name includes the directory.
AbstractDiscretization * getSpatialDiscretization() const
Link to the spatial discretization (FE, FV, etc)
Unknown * getUnknown(const CepsString &label) const
Get an unknown by its name.
CepsBool writesGlobalIndices() const
Tells if global indices are written on top of solution.
CepsReal getTimeStep() const
pde time step
CepsBool allPointsHaveBeenActivated() const
Tells if all points have seen AP start (checked with activation threshold)
CardiacProblem * m_problem
Link to problem structure.
DHVecPtr m_activationTimes
Values of activation times at each point.
void writeActivationMap()
Writes activation times and probe points data.
CepsMap< CepsUnknownIndex, CepsSet< CepsDofGlobalIndex > > m_foundAPD
Flag map.
static constexpr CepsUInt _apdpctg
Index in activation data.
TimeWriter * m_timeWriter
Link to the solver's time writer, if needed...
~ActivationTracker()
Destructor.
DHVecPtr m_APD
length of AP (?)
CepsString getByeByeMessage() const
Message to be displayed at the end of computation.
DHVecPtr m_peakTimes
Times of max potential.
void update(CepsInt iter, CepsReal time, DHVecPtr solution, DHVecPtr prevSolution)
Writes the solution (optionnally currents) every m_nbIterSnapshot steps only. Also updates activation...
DHVecPtr m_APD50
length of AP to get to 50% depol
CepsMap< CepsUnknownIndex, CepsSet< CepsDofGlobalIndex > > m_foundPeak
Flag map.
void setupWithParameters(InputParameters *params)
Initializes attributes from text input.
ActivationTracker(CardiacSolver *solver)
Constructor.
CepsMap< CepsUnknownIndex, CepsSet< CepsDofGlobalIndex > > m_activationSeen
Flag map.
static constexpr CepsUInt _threshold
Index in activation data.
CepsUInt m_nbIterPostProcess
Output periodicity.
CepsMap< CepsUnknownIndex, CepsSet< CepsDofGlobalIndex > > m_activationNotYetSeen
Flag map.
DHVecPtr m_peakValues
Value of max potential.
CepsMap< CepsUnknownIndex, CepsSet< CepsDofGlobalIndex > > m_foundAPD50
Flag map.
CepsMap< CepsUnknownIndex, CepsReal3D > m_activationTimeData
AP analysis.
CepsUInt m_nToBeSeen
Number of dofs in tissue for each activation time data.
CepsReal m_tissueVolume
Reference volume.
DHVecPtr m_activated
1/0 status of point (above/below threshold)
static constexpr CepsUInt _minV4Peak
Index in activation data.
CepsBool allPointsHaveBeenRepolarized() const
Tells if all points have seen AP end (checked with APD percentage)
void initializeActivationMap()
Allocates arrays for activation detection.
CepsVector< CepsReal > m_activatedVolume
Size of tissue that is above activation threshold.
CepsVector< CepsReal > & getActivatedVolume()
Returns reference to data, so it can be linked to a TimeWriter.
CepsBool allSeen(const CepsMap< CepsUnknownIndex, CepsSet< CepsDofGlobalIndex >> &) const
Check not nans for given array.
virtual CepsVector< Unknown * > getTMVUnknowns() const =0
Returns a vector containing all unknowns that are a TMV (especially useful for bilayer)
const CepsSet< CepsAttribute > & getTissueAttributes() const
All attributes that localize tissue.
Solves cardiac problems, that all share the same structure.
static Profiler m_profiler
The same profiler for each big object.
A degree of freedom for any kind of problem The dof can be associated to a geometrical element or not...
const CepsVector< _Type > & getOwned() const
Get data owned by the processor, const.
const CepsVector< _Type > & getHalo() const
Get halo data owned by neighbor processor, const.
Computes the integral of a quantity on the whole domain or subdomains, using a FE matrix.
CepsReal integrate(DHVecPtr u, DMatPtr mat=nullptr)
Returns the value of the integral by computing ones dot Mu.
void stop(CepsString lbl)
Stops the measure of a labeled chronometer.
void start(CepsString lbl, CepsString dspl="")
Creates or continue a labeled chronometer.
void addCustomData(const CepsString &name, CepsReal *data)
Add a custom data to be written in the outputfile. Custom data cannot be added after header has been ...
A class used to defined an unknown of a PDE problem The unknown can be defined on a specific region,...
const CepsString & getName() const
Get the name of the unknown.
A class that enables the output of binary parallel VTK format files.
void addScalarData(const DHVecPtr &v, const CepsVector< CepsString > &fieldNames, const CepsVector< Unknown * > &us)
Set multiple scalar fields to be output by this writer. addScalarData for several unknowns.
void write(CepsReal time=0., CepsBool writeXmlEntry=true)
Write all stored data.
CepsString toString(_Tp value)
Convert a given value to a string (input has to be compatible with std::to_string)
MPI_Comm getCommunicator()
Get the communicator.
CepsBool isValidPtr(_Type *ptr)
Tells if pointer is not null.
CepsUInt getGridSize()
Returns the number of process on the computing grid.
CepsReal3D readVertex(std::istream &file, const CepsString &errorMessage="")
Reads an integral number from an istream, aborts if conversion fails advances the stream by 1 word.
CepsInt readInt(std::istream &file, const CepsString &errorMessage="")
Reads an integral number from an istream, aborts if conversion fails advances the stream by 1 word.
CepsBool isNullPtr(_Type *ptr)
Tells if passed pointer is null.
CepsVector< CepsString > split(const CepsString &s, const CepsString &delimiters=CepsString(" \t"))
Splits a string using mulitple delimiters in a single string.
CepsBool isProfiling()
Check if we are currently profiling on the master proc (always false on slave procs).
void destroyObject(_Type &)
Destroy[delete] any type.