LBIBCell
 All Classes Functions Variables Friends Pages
tutorial_01_BioSolverDifferentiation.cpp
1 /* Copyright (c) 2013 David Sichau <mail"at"sichau"dot"eu>
2  * 2013-2015 Simon Tanaka <tanakas"at"gmx"dot"ch>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 #include <LbmLib/include/solver/BioSolver/tutorial_01_BioSolverDifferentiation.hpp>
23 #include <LbmLib/include/geometry/GeometryHandler.hpp>
24 #include <LbmLib/include/GlobalSimulationParameters.hpp>
25 #include <vector>
26 #include <string>
27 #include <iostream>
28 #include <memory>
29 #include <mutex>
30 
31 namespace LbmLib {
32 namespace solver {
33 namespace{
34  const unsigned int FREQUENCY = 100;
35  const double THRESHOLD = 1.6;
36  std::once_flag flag;
37 }
38 
39 tutorial_01_BioSolverDifferentiation::tutorial_01_BioSolverDifferentiation() : BioBaseSolver()
40 {}
41 
43  geometry::GeometryHandler& geometryhandler,
44  solver::ForceSolver& forcesolver
45  ) {
46 
47  if (Parameters.getCurrentIteration()%FREQUENCY != 0) {
48  return;
49  }
50 
51  // step 1: compute accumulated concentrations per domain [domainID,accumulatedconentration]
52  std::map<unsigned int,double> accumulatedcellconcentrationmap =
53  geometryhandler.computeAccumulatedDomainConcentrations("tutorial_01_CDESolverD2Q5_SIGNAL");
54 
55  // step 2: update cellDefinition_
56  this->cellDefinition_.clear();
57  for (auto it : geometryhandler.getGeometry().getConnections()) {
58  this->cellDefinition_[(*it).getDomainIdentifier()].push_back(it);
59  }
60 
61  // step 2b: initialize cellTypeTracker_ (only once!)
62  std::call_once(flag, [this,&geometryhandler](){
63  geometryhandler.getCellTypeTrackerMap().clear();
64  geometryhandler.getCellTypeTrackerMap()[0] = 0; // fluid default
65  for (auto it : this->cellDefinition_) { // default all other cells to type 1
66  geometryhandler.getCellTypeTrackerMap()[it.first] = 1;
67  }
68  });
69 
70  // step 3: differentiate accordingly
71  for(std::map<unsigned int,double>::iterator it = ++accumulatedcellconcentrationmap.begin(); //skip extracellular domain
72  it != accumulatedcellconcentrationmap.end();
73  it++) {
74  if (it->second < THRESHOLD) {
75  geometryhandler.getCellTypeTrackerMap()[it->first] = 2;
76  }
77  }
78 
79  // step 4: copy cell types to all physical nodes:
80  geometryhandler.copyCellTypeToPhysicalNodes(
81  geometryhandler.getCellTypeTrackerMap()
82  );
83 }
84 
85 const std::string tutorial_01_BioSolverDifferentiation::name = "tutorial_01_BioSolverDifferentiation";
86 }
87 } // end namespace
88 
void copyCellTypeToPhysicalNodes(std::map< unsigned int, unsigned int > &celltrackermap)
update the celltypes of all *PhysicalNode*s with domainid
The actual force solver.
Definition: ForceSolver.hpp:43
std::map< unsigned int, double > computeAccumulatedDomainConcentrations(const std::string &name) const
Compute the accumulated concentrations of species name in all domains.
const Geometry & getGeometry() const
getter for the geometry
const std::vector< std::shared_ptr< Connection > > & getConnections() const
getConnections Getter for connections
Definition: Geometry.cpp:391
virtual void applyBioProcess(geometry::GeometryHandler &geometryhandler, solver::ForceSolver &forcesolver)
Applies biological processes.
std::map< unsigned int, unsigned int > & getCellTypeTrackerMap(void)
Returns a reference to the cellTypeTrackerMap.
class responsible for generating the internal geometry representation