LBIBCell
 All Classes Functions Variables Friends Pages
tutorial_01_BioSolverMembraneTension.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_BioSolverMembraneTension.hpp>
23 #include <LbmLib/include/geometry/GeometryHandler.hpp>
24 #include <LbmLib/include/solver/ForceSolver.hpp>
25 #include <LbmLib/include/GlobalSimulationParameters.hpp>
26 #include <vector>
27 #include <string>
28 #include <iostream>
29 #include <omp.h>
30 
31 namespace LbmLib {
32 namespace solver {
33 namespace {
34  const unsigned int FREQUENCY = 10;
35  const double FORCE = 0.01;
36  class Connection;
37 }
38 
39 tutorial_01_BioSolverMembraneTension::tutorial_01_BioSolverMembraneTension() : BioBaseSolver()
40 {}
41 
43  geometry::GeometryHandler& geometryhandler,
44  solver::ForceSolver& forcesolver
45  ) {
46  std::stringstream forcedescriptor;
47  auto tempconnectionmap = geometryhandler.getGeometry().getConnections();
48 
49  if (Parameters.getCurrentIteration()%FREQUENCY != 0) {
50  return;
51  }
52 
53  // step 1: clear all forces:
54  forcesolver.deleteForceType(6);
55 
56  // step 2: renew all tensions:
57 #pragma omp parallel for schedule(static) private(forcedescriptor)
58  for (size_t j=0;
59  j<tempconnectionmap.size();
60  ++j) {
61  forcedescriptor.str( std::string() ); // reset
62  forcedescriptor.clear(); //clear flags
63  forcedescriptor << "6\t" // type
64  << tempconnectionmap[j]->getGeometryNodes().first->getId() << "\t" // nodeID 1
65  << tempconnectionmap[j]->getGeometryNodes().second->getId() << "\t" // nodeID 2
66  << FORCE;
67  forcesolver.addForce(&forcedescriptor);
68 
69  forcedescriptor.str( std::string() ); // reset
70  forcedescriptor.clear(); //clear flags
71  forcedescriptor << "6\t" // type
72  << tempconnectionmap[j]->getGeometryNodes().second->getId() << "\t" // nodeID 2
73  << tempconnectionmap[j]->getGeometryNodes().first->getId() << "\t" // nodeID 1
74  << FORCE;
75  forcesolver.addForce(&forcedescriptor);
76  }
77 }
78 
79 const std::string tutorial_01_BioSolverMembraneTension::name = "tutorial_01_BioSolverMembraneTension";
80 }
81 } // end namespace
82 
void deleteForceType(const unsigned int forcetype)
reset all forces
The actual force solver.
Definition: ForceSolver.hpp:43
const Geometry & getGeometry() const
getter for the geometry
virtual void applyBioProcess(geometry::GeometryHandler &geometryhandler, solver::ForceSolver &forcesolver)
Applies biological processes.
const std::vector< std::shared_ptr< Connection > > & getConnections() const
getConnections Getter for connections
Definition: Geometry.cpp:391
void addForce(std::stringstream *const forcedescriptor)
add a force
class responsible for generating the internal geometry representation