LBIBCell
 All Classes Functions Variables Friends Pages
BioSolverHookeanMembraneTension.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/BioSolverHookeanMembraneTension.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 K = 0.01;
36  const double l_resting = 0.05;
37  class Connection;
38 }
39 
40 BioSolverHookeanMembraneTension::BioSolverHookeanMembraneTension() : BioBaseSolver()
41 {}
42 
44  geometry::GeometryHandler& geometryhandler,
45  solver::ForceSolver& forcesolver
46  ) {
47  std::stringstream forcedescriptor;
48  auto tempconnectionmap = geometryhandler.getGeometry().getConnections();
49 
50  if (Parameters.getCurrentIteration()%FREQUENCY != 0) {
51  return;
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 << "0\t" // type
64  << tempconnectionmap[j]->getGeometryNodes().first->getId() << "\t" // nodeID 1
65  << tempconnectionmap[j]->getGeometryNodes().second->getId() << "\t" // nodeID 2
66  << K << "\t" // spring constant
67  << l_resting; // resting length
68  forcesolver.addForce(&forcedescriptor);
69 
70  forcedescriptor.str( std::string() ); // reset
71  forcedescriptor.clear(); //clear flags
72  forcedescriptor << "0\t" // type
73  << tempconnectionmap[j]->getGeometryNodes().second->getId() << "\t" // nodeID 2
74  << tempconnectionmap[j]->getGeometryNodes().first->getId() << "\t" // nodeID 1
75  << K << "\t" // spring consant
76  << l_resting; // resting length
77  forcesolver.addForce(&forcedescriptor);
78  }
79 }
80 
81 const std::string BioSolverHookeanMembraneTension::name = "BioSolverHookeanMembraneTension";
82 }
83 } // end namespace
84 
void deleteForceType(const unsigned int forcetype)
reset all forces
The actual force solver.
Definition: ForceSolver.hpp:43
virtual void applyBioProcess(geometry::GeometryHandler &geometryhandler, solver::ForceSolver &forcesolver)
Applies biological processes.
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
void addForce(std::stringstream *const forcedescriptor)
add a force
class responsible for generating the internal geometry representation