File: KinemC__Engine.cpp

package info (click to toggle)
yade 2026.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,448 kB
  • sloc: cpp: 97,645; python: 52,173; sh: 677; makefile: 162
file content (136 lines) | stat: -rw-r--r-- 4,645 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*************************************************************************
*  Copyright (C) 2008 by Jerome Duriez                                   *
*  jerome.duriez@hmg.inpg.fr                                             *
*                                                                        *
*  This program is free software; it is licensed under the terms of the  *
*  GNU General Public License v2 or later. See file LICENSE for details. *
*************************************************************************/

#include <pkg/dem/KinemC__Engine.hpp>

namespace yade { // Cannot have #include directive inside.

YADE_PLUGIN((KinemCTDEngine)(KinemCNDEngine)(KinemCNLEngine)(KinemCNSEngine));

void KinemCTDEngine::action()
{
	KinemSimpleShearBox::getBoxes_Dt();


	scene->forces.sync();
	Real current_NormalForce = (scene->forces.getForce(id_topbox)).y();
	KinemSimpleShearBox::computeScontact();
	current_sigma = current_NormalForce / (1000.0 * Scontact); // so we have the current value of sigma, in kPa

	if (((compSpeed > 0) && (current_sigma < targetSigma)) || ((compSpeed < 0) && (current_sigma > targetSigma))) {
		if (temoin != 0) temoin = 0;

		letMove(0.0, -compSpeed * dt);
	} else if (temoin == 0) {
		stopMovement();
		string f;
		if (compSpeed > 0) f = "Sigmax_";
		else
			f = "Sigmin_";

		Omega::instance().saveSimulation(Key + f + boost::lexical_cast<string>(floor(targetSigma)) + "kPaReached.xml");
		temoin = 1;
	}


	for (unsigned int j = 0; j < sigma_save.size(); j++) {
		if ((((compSpeed > 0) && (current_sigma > sigma_save[j])) || ((compSpeed < 0) && (current_sigma < sigma_save[j]))) && (temoin_save[j] == 0)) {
			stopMovement();
			Omega::instance().saveSimulation(Key + "SigInt_" + boost::lexical_cast<string>(floor(current_sigma)) + "kPareached.xml");
			temoin_save[j] = 1;
		}
	}
}

void KinemCNDEngine::action()
{
	KinemSimpleShearBox::getBoxes_Dt();

	if (((shearSpeed > 0) && (gamma <= gammalim)) || ((shearSpeed < 0) /*&& (gamma>=gammalim)*/)) {
		if (temoinfin != 0) temoinfin = 0;
		letMove(shearSpeed * dt, 0);
		gamma += shearSpeed * dt;
	} else {
		stopMovement();
		if (temoinfin == 0) {
			Omega::instance().saveSimulation(Key + "endShear.xml");
			temoinfin = 1;
		}
	}

	for (unsigned int j = 0; j < gamma_save.size(); j++) {
		if ((((shearSpeed > 0) && (gamma > gamma_save[j])) || ((shearSpeed < 0) && (gamma < gamma_save[j]))) && (temoin_save[j] == 0)) {
			stopMovement(); // reset of all the speeds before the save
			Omega::instance().saveSimulation(Key + "_" + boost::lexical_cast<string>(floor(gamma * 1000)) + "mmsheared.xml");
			temoin_save[j] = 1;
		}
	}
}

void KinemCNLEngine::action()
{
	if (LOG) cout << "debut applyCondi du CNCEngine !!" << endl;
	KinemSimpleShearBox::getBoxes_Dt();

	if (LOG) cout << "gamma = " << boost::lexical_cast<string>(gamma) << "  et gammalim = " << boost::lexical_cast<string>(gammalim) << endl;
	if (gamma <= gammalim) {
		if (LOG) cout << "Je suis bien dans la partie gamma < gammalim" << endl;
		if (temoin == 0)

		{
			if (LOG) cout << "Je veux maintenir la Force a f0 = : " << f0 << endl;
			temoin = 1;
		}
		computeDY(0.0);

		letMove(shearSpeed * dt, deltaH);
		gamma += shearSpeed * dt;

	} else if (temoin < 2) {
		stopMovement();
		it_stop = scene->iter;
		cout << "Shear stopped : gammaLim reached at it " << it_stop << endl;
		temoin = 2;
	} else if (temoin == 2 && (scene->iter == (it_stop + 5000))) {
		Omega::instance().saveSimulation(Key + "endShear" + boost::lexical_cast<string>(scene->iter) + ".xml");
		Omega::instance().pause();
	}

	for (unsigned int j = 0; j < gamma_save.size(); j++) {
		if ((gamma > gamma_save[j]) && (temoin_save[j] == 0)) {
			stopMovement(); // reset of all the speeds before the save
			Omega::instance().saveSimulation(
			        Key + "_" + boost::lexical_cast<string>(floor(gamma * 1000)) + "_"
			        + boost::lexical_cast<string>(floor(gamma * 10000) - 10 * floor(gamma * 1000)) + "mmsheared.xml");
			temoin_save[j] = 1;
		}
	}
}

void KinemCNSEngine::action()
{
	if (LOG) cerr << "debut applyCondi !!" << endl;
	KinemSimpleShearBox::getBoxes_Dt();

	if (gamma <= gammalim) {
		computeDY(KnC);
		letMove(shearSpeed * dt, deltaH);
		gamma += shearSpeed * dt;
		if (temoin == 0) { temoin = 1; }
	} else if (temoin < 2) {
		stopMovement();
		it_stop = scene->iter;
		cout << "Cisaillement arrete : gammaLim atteint a l'iteration " << it_stop << endl;
		temoin = 2;
	} else if (temoin == 2 && (scene->iter == (it_stop + 5000))) {
		Omega::instance().saveSimulation(Key + "finCis" + boost::lexical_cast<string>(scene->iter) + ".xml");
		Omega::instance().pause();
	}
}

} // namespace yade