LBIBCell
 All Classes Functions Variables Friends Pages
tutorial_02_BioSolverGrowth.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_02_BioSolverGrowth.hpp>
23 #include <LbmLib/include/geometry/GeometryHandler.hpp>
24 #include <LbmLib/include/GlobalSimulationParameters.hpp>
25 #include <LbmLib/include/nodes/PhysicalNode.hpp>
26 #include <LbmLib/include/solver/CDESolver/CDEAbstractSolver.hpp>
27 
28 #include <vector>
29 #include <string>
30 #include <iostream>
31 namespace LbmLib {
32 namespace solver {
33 
34 namespace {
35  const unsigned int FREQUENCY = 1;
36  const double MAXSOURCE = 0.001;
37  const double THRESHOLD = 1.0;
38 }
39 
40 tutorial_02_BioSolverGrowth::tutorial_02_BioSolverGrowth() : BioBaseSolver()
41 {}
42 
44  geometry::GeometryHandler& geometryhandler,
45  solver::ForceSolver& forcesolver
46  ) {
47 
48  if (Parameters.getCurrentIteration()%FREQUENCY != 0) {
49  return;
50  }
51 
52  double conc_R;
53  double conc_L;
54  double source;
55 
56  // add mass to the cells:
57 #pragma omp parallel for schedule(dynamic)
58  for (unsigned int ity = 0;
59  ity < geometryhandler.getPhysicalNodes().size();
60  ity++) { // loop y direction
61  for (unsigned int itx = 0;
62  itx < geometryhandler.getPhysicalNodes()[0].size();
63  itx++) { // loop x direction
64  if (geometryhandler.getPhysicalNodes()[ity][itx]->getDomainIdentifier() != 0 ) {
65 
66  conc_R = geometryhandler.getPhysicalNodes()[ity][itx]->getCDESolverSlow("tutorial_02_CDESolverD2Q5_R").getC();
67  conc_L = geometryhandler.getPhysicalNodes()[ity][itx]->getCDESolverSlow("tutorial_02_CDESolverD2Q5_L").getC();
68 
69  if (conc_R*conc_R*conc_L > THRESHOLD) {
70  source = MAXSOURCE;
71  }
72  else {
73  source = MAXSOURCE/10.0;
74  }
75 
76  geometryhandler.getPhysicalNodes()[ity][itx]->getFluidSolver().addMass(source);
77  }
78  }
79  }
80 }
81 
82 const std::string tutorial_02_BioSolverGrowth::name = "tutorial_02_BioSolverGrowth";
83 }
84 } // end namespace
85 
The actual force solver.
Definition: ForceSolver.hpp:43
virtual void applyBioProcess(geometry::GeometryHandler &geometryhandler, solver::ForceSolver &forcesolver)
Applies biological processes.
const std::vector< std::vector< nodes::PhysicalNode * > > & getPhysicalNodes() const
getPhysicalNodes Getter method for the physical node grid
class responsible for generating the internal geometry representation