Skip to content

Commit 9b56026

Browse files
committed
Work in progress. Does not compile.
1 parent 814195c commit 9b56026

8 files changed

+296
-6
lines changed

src/aligner/external/external_aligner.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ class ExternalAlign
6262
m_has_params(false)
6363
{ }
6464

65+
66+
virtual ~ExternalAlign() { }
67+
6568
//! Set pair parameters data for external alignment
6669
virtual void set_parameters(pairs_type&) = 0;
6770

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/* ***************************************************************************
2+
*
3+
* Copyright (C) 2013-2016 University of Dundee
4+
* All rights reserved.
5+
*
6+
* This file is part of SAMoS (Soft Active Matter on Surfaces) program.
7+
*
8+
* SAMoS is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* SAMoS is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
* ****************************************************************************/
22+
23+
/*!
24+
* \file external_piv_aligner.cpp
25+
* \author Rastko Sknepnek, [email protected]
26+
* \date 11-Apr-2015
27+
* \brief Declaration of ExternalPIVAlign class
28+
*/
29+
30+
31+
#include "external_piv_aligner.hpp"
32+
33+
void ExternalPIVAlign::compute()
34+
{
35+
int N = m_system->size();
36+
double hx = m_hx, hy = m_hy, hz = m_hz;
37+
38+
for (int i = 0; i < N; i++)
39+
{
40+
Particle& pi = m_system->get_particle(i);
41+
if (m_has_params)
42+
{
43+
hx = m_type_params[pi.get_type()-1].hx;
44+
hy = m_type_params[pi.get_type()-1].hy;
45+
hz = m_type_params[pi.get_type()-1].hz;
46+
}
47+
pi.tau_x += hy*pi.nz - hz*pi.ny;
48+
pi.tau_y += hz*pi.nx - hx*pi.nz;
49+
pi.tau_z += hx*pi.ny - hy*pi.nx;
50+
}
51+
}
52+
53+
// Private member function
54+
void ExternalPIVAlign::__read_csv(const string & fame, PIVData & data)
55+
{
56+
ifstream f(fname.c_str());
57+
while (f.good())
58+
{
59+
string line;
60+
getline(f, line);
61+
if (line.length() > 0)
62+
{
63+
istringstream buffer(line);
64+
string sval;
65+
vector<double> fline;
66+
while (getline(buffer, sval, ','))
67+
fline.push_back(stod(sval));
68+
data.piv_data.push_back(fline);
69+
}
70+
}
71+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
/* ***************************************************************************
2+
*
3+
* Copyright (C) 2013-2016 University of Dundee
4+
* All rights reserved.
5+
*
6+
* This file is part of SAMoS (Soft Active Matter on Surfaces) program.
7+
*
8+
* SAMoS is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* SAMoS is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
* ****************************************************************************/
22+
23+
/*!
24+
* \file external_piv_aligner.hpp
25+
* \author Rastko Sknepnek, [email protected]
26+
* \date 31-Jan-2020
27+
* \brief Declaration of ExternalPIVAlign class
28+
*/
29+
30+
#ifndef __EXTERNAL_PIV_ALIGN_HPP__
31+
#define __EXTERNAL_PIV_ALIGN_HPP__
32+
33+
#include <cmath>
34+
#include <vector>
35+
#include <string>
36+
#include <sstream>
37+
38+
#include <boost/filesystem.hpp>
39+
40+
#include "external_aligner.hpp"
41+
42+
using std::istringstream;
43+
using std::make_pair;
44+
using std::sqrt;
45+
using std::string;
46+
using std::vector;
47+
using namespace boost::filesystem;
48+
49+
//! Structure that handles parameters for the polar alignment
50+
struct PIVData
51+
{
52+
vector<vector<double>> piv_data;
53+
};
54+
55+
struct PIVAlignParameters
56+
{
57+
double gamma; // Alignment strength
58+
}
59+
60+
/*! ExternalPIVAlign implements the alignment to the velocity field obtained from
61+
* experiments in embryos. Given a local vector vector \f$ \vec v_i \f$. Torque on particle \f$ i \f$ is then
62+
* \f$ \vec \tau_i = \gamma \vec v_i \times \vec n_i \f$, where \f$ \gamma \f$ is a constant. We note that
63+
* valued of \f$ \vec v_i \f$ are interpolated between two consecutive time steps (current and the one ahead).
64+
* All cells are binned into boxes (given by the PIV resolution). Each cell is aligned to the vector \f$ \vec v_i \f$
65+
* of the box it falls into.
66+
* \note: One could do a more sophisticaed spatial and temporal interpolation.
67+
*/
68+
class ExternalPIVAlign : public ExternalAlign
69+
{
70+
public:
71+
72+
//! Constructor
73+
//! \param sys Pointer to the System object
74+
//! \param msg Pointer to the internal state messenger
75+
//! \param param Contains information about all parameters
76+
ExternalPIVAlign(SystemPtr sys, MessengerPtr msg, pairs_type& param) : ExternalAlign(sys,msg,param)
77+
{
78+
int ntypes = m_system->get_ntypes();
79+
if (param.find("xfile") == param.end())
80+
{
81+
m_msg->msg(Messenger::ERROR,"External PIV aligner. No x component of file external PIV given.");
82+
throw runtime_error("No x component file provided for the external PIV alignment.");
83+
}
84+
else
85+
{
86+
path p(param["xfile"]);
87+
if (exists(p))
88+
{
89+
this->__read_csv(param["xfile"], m_x);
90+
}
91+
else
92+
throw runtime_error("File " + param["xfile"] + " does not exist.");
93+
}
94+
if (param.find("hx") == param.end())
95+
{
96+
m_msg->msg(Messenger::WARNING,"External PIV aligner. No x component of external PIV given. Assuming 0.");
97+
m_hx = 0.0;
98+
}
99+
else
100+
{
101+
m_msg->msg(Messenger::INFO,"External PIV aligner. x component of the external PIV set to "+param["hx"]+".");
102+
m_hx = lexical_cast<double>(param["hx"]);
103+
}
104+
m_msg->write_config("aligner.external.PIV.hx",lexical_cast<string>(m_hx));
105+
if (param.find("hy") == param.end())
106+
{
107+
m_msg->msg(Messenger::WARNING,"External PIV aligner. No y component of external PIV given. Assuming 0.");
108+
m_hy = 0.0;
109+
}
110+
else
111+
{
112+
m_msg->msg(Messenger::INFO,"External PIV aligner. y component of the external PIV set to "+param["hy"]+".");
113+
m_hy = lexical_cast<double>(param["hy"]);
114+
}
115+
m_msg->write_config("aligner.external.PIV.hy",lexical_cast<string>(m_hy));
116+
if (param.find("hz") == param.end())
117+
{
118+
m_msg->msg(Messenger::WARNING,"External PIV aligner. No z component of external PIV given. Assuming 0.");
119+
m_hz = 0.0;
120+
}
121+
else
122+
{
123+
m_msg->msg(Messenger::INFO,"External PIV aligner. z component of the external PIV set to "+param["hz"]+".");
124+
m_hz = lexical_cast<double>(param["hz"]);
125+
}
126+
m_msg->write_config("aligner.external.PIV.hz",lexical_cast<string>(m_hz));
127+
128+
m_type_params = new PIVAlignParameters[ntypes];
129+
for (int i = 0; i < ntypes; i++)
130+
{
131+
m_type_params[i].gamma = m_gamma;
132+
}
133+
}
134+
135+
virtual ~ExternalPIVAlign()
136+
{
137+
delete [] m_type_params;
138+
}
139+
140+
//! Set pair parameters data for self alignment
141+
void set_parameters(pairs_type& self_param)
142+
{
143+
map<string,double> param;
144+
int type;
145+
146+
if (self_param.find("type") == self_param.end())
147+
{
148+
m_msg->msg(Messenger::ERROR,"Type has not been defined for external PIV alignment.");
149+
throw runtime_error("Missing key for external alignment parameters.");
150+
}
151+
152+
type = lexical_cast<int>(self_param["type"]);
153+
154+
155+
if (self_param.find("hx") != self_param.end())
156+
{
157+
m_msg->msg(Messenger::INFO,"External PIV aligner. Setting x component of external filed to "+self_param["hx"]+" for particle pair of type ("+lexical_cast<string>(type)+").");
158+
param["hx"] = lexical_cast<double>(self_param["hx"]);
159+
}
160+
else
161+
{
162+
m_msg->msg(Messenger::INFO,"External PIV aligner. Using default x component of external filed ("+lexical_cast<string>(m_hx)+") for particle pair of types ("+lexical_cast<string>(type)+")");
163+
param["hx"] = m_hx;
164+
}
165+
m_msg->write_config("aligner.external.PIV.type."+self_param["type"]+".hx",lexical_cast<string>(param["hx"]));
166+
if (self_param.find("hy") != self_param.end())
167+
{
168+
m_msg->msg(Messenger::INFO,"External PIV aligner. Setting y component of external filed to "+self_param["hy"]+" for particle pair of type ("+lexical_cast<string>(type)+").");
169+
param["hy"] = lexical_cast<double>(self_param["hy"]);
170+
}
171+
else
172+
{
173+
m_msg->msg(Messenger::INFO,"External PIV aligner. Using default y component of external filed ("+lexical_cast<string>(m_hy)+") for particle pair of types ("+lexical_cast<string>(type)+")");
174+
param["hy"] = m_hy;
175+
}
176+
m_msg->write_config("aligner.external.PIV.type."+self_param["type"]+".hy",lexical_cast<string>(param["hy"]));
177+
if (self_param.find("hz") != self_param.end())
178+
{
179+
m_msg->msg(Messenger::INFO,"External PIV aligner. Setting z component of external filed to "+self_param["hz"]+" for particle pair of type ("+lexical_cast<string>(type)+").");
180+
param["hz"] = lexical_cast<double>(self_param["hz"]);
181+
}
182+
else
183+
{
184+
m_msg->msg(Messenger::INFO,"External PIV aligner. Using default z component of external filed ("+lexical_cast<string>(m_hz)+") for particle pair of types ("+lexical_cast<string>(type)+")");
185+
param["hz"] = m_hz;
186+
}
187+
m_msg->write_config("aligner.external.PIV.type."+self_param["type"]+".hz",lexical_cast<string>(param["hz"]));
188+
189+
m_type_params[type-1].hx = param["hx"];
190+
m_type_params[type-1].hy = param["hy"];
191+
m_type_params[type-1].hz = param["hz"];
192+
193+
m_has_params = true;
194+
}
195+
196+
197+
//! Computes "torques"
198+
void compute();
199+
200+
201+
private:
202+
203+
PIVData m_x; // x components of the grid
204+
PIVData m_y; // y components of the grid
205+
vector<PIVData> m_u; // Holds x components of the velocity over time
206+
vector<PIVData> m_v; // Holds y components of the velocity over time
207+
int m_max_time; // Total number of time steps
208+
int m_step_gap; // Number of steps between two consecutive PIV snapshots
209+
double m_gamma; // Alignment strength
210+
211+
void __read_csv(const string &, PIVData &);
212+
};
213+
214+
typedef shared_ptr<ExternalPIVAlign> ExternalPIVAlignPtr;
215+
216+
#endif
217+

src/log/logger.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include <string>
3636
#include <map>
3737
#include <list>
38-
#include <boost/make_shared.hpp>
3938
#include <boost/format.hpp>
4039
#include <boost/algorithm/string.hpp>
4140
#include <boost/lexical_cast.hpp>

src/population/population.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ class Population
116116
string m_group_name; //!< Name of the group to apply this population to
117117
int m_freq; //!< Frequency (in the number of time steps) with which to attempt population control
118118
double m_l_rescale; //!< Rescale particle length by total of this amount
119-
int m_l_rescale_steps; //!< Rescale particle lenght over this many steps
120-
double m_l_scale; //!< Rescale particle lenth by this much in each step (=m_l_rescale**(m_grow_l_freq/m_l_rescale_steps))
119+
int m_l_rescale_steps; //!< Rescale particle length over this many steps
120+
double m_l_scale; //!< Rescale particle length by this much in each step (=m_l_rescale**(m_grow_l_freq/m_l_rescale_steps))
121121
bool m_has_nlist; //!< If true, population has neighbour list set
122122

123123
};

src/potentials/external/external_boundary_pull.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535

3636
/*! ExternalBoundaryPull handles pulling force onto the boundary of a tissue layer.
37-
* For a boundary particle \f$ i $\f we apply a force of magnitude \f$ \alpha \f$ in
37+
* For a boundary particle \f$ i \f$ we apply a force of magnitude \f$ \alpha \f$ in
3838
* the direction \f$ -\left(\vec r{ji} + \vec r_{ki}\right) \f$, where \f$ \vec r_{ji} \f$
3939
* in the vecror along the edge connecting particle \f$ i \f$ and it boundary neighbour
4040
* \f$ j \f$. Similarly, \f$ \vec r_{ki} $\f is the vector connecting particle \f$ i \f$

src/potentials/pair/pair_boundary_attraction_potential.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct BoundaryAttractionParameters
5050
/*! PairBoundaryAttractionPotential implements the attraction between boundary cells and the bulk in the active vertex tissue model.
5151
* Force is only existed on the boundary cells and is modelled based on the corase-grained model of Cooke, at al. (Phys. Rev. E 72, 011506 (2005)).
5252
* If the distance between cell centres is between \f$ r_c $\f and \f$ r_c + w_c $\f force is equal to
53-
* \f$ -\frac{\pi\varepsilon}{2w_c}\sin\left(\frac{\pi(r_{ij}-r_c)}{w_c}\right){\hat\vec r}_{ij} $\f,
53+
* \f$ -\frac{\pi\varepsilon}{2w_c}\sin\left(\frac{\pi(r_{ij}-r_c)}{w_c}\right){\hat\vec r}_{ij} \f$,
5454
* where \f$ \varepsilon $\f measures interaction strength.
5555
*/
5656
class PairBoundaryAttractionPotential : public PairPotential

src/potentials/potential.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ typedef map<string,AnglePotentialPtr> AnglePotType;
5252

5353
/*! Potential class handles all potentials (pair interactions, external forces, bonds and angles) present
5454
* in the system. All potentials are stored in two STL maps which both have strings as keys
55-
* while items are pointers (boost shared_ptr) to the PairPotential and ExternalPotential abstract classes,
55+
* while items are pointers (std shared_ptr) to the PairPotential and ExternalPotential abstract classes,
5656
* respectively. The integrator part of the code calls member functions of this class
5757
* to perform actual force and potential computations.
5858
*/

0 commit comments

Comments
 (0)