Skip to content

Commit 11217e3

Browse files
author
Thomas Scrase
committed
Add method to pin/unpin plastic data. Also added a default steady plastic time-stepper
1 parent 1b0dbd8 commit 11217e3

File tree

2 files changed

+98
-23
lines changed

2 files changed

+98
-23
lines changed

src/solid/solid_plastic_elements.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ template class QPlasticPVDElement<3, 2>;
1818
template<unsigned DIM>
1919
RankFourTensor<double> PlasticEquations<DIM>::Dummy_rankfourtensor;
2020

21+
template<unsigned DIM>
22+
Steady<1> PlasticEquations<DIM>::Default_plastic_timestepper;
23+
2124
/*
2225
* \details Computes the Caucystress using the plastic deformation gradient
2326
*/

src/solid/solid_plastic_elements.h

Lines changed: 95 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ namespace oomph
7070
// differenced
7171
Vector<Vector<double*>> Plastic_dof_data_pt;
7272

73-
7473
// Keeps track of if data for the plastic dof numbers has been allocated
7574
// We do it within this function because this allows us to reliably zero the
7675
// counters Num_plastic_Dofs and Num_plastic_residuals
@@ -85,11 +84,77 @@ namespace oomph
8584
// A pointer to the plastic constitutive law
8685
PlasticConstitutiveLaw* Plastic_consitutive_law_pt;
8786

87+
// By default we assume that the plastic solve is steady for which we
88+
// require a single history value
89+
static Steady<1> Default_plastic_timestepper;
90+
91+
// Pin the plastic dof of type data_type at the integral point, if index<0
92+
// then pin all plastic data of that type, otherwise pin the value specified
93+
void pin_plastic_dof(const unsigned& ipt,
94+
const unsigned& data_type,
95+
const int& index = -1)
96+
{
97+
if (index < 0)
98+
{
99+
const unsigned nvalue =
100+
Plastic_data_pinned_status[ipt][data_type].size();
101+
for (unsigned i = 0; i < nvalue; i++)
102+
{
103+
Plastic_data_pinned_status[ipt][data_type][i] = true;
104+
}
105+
}
106+
else
107+
{
108+
#ifdef PARANOID
109+
// Check if the index makes sense
110+
if (index > Plastic_data_pinned_status[ipt][data_type].size() - 1)
111+
{
112+
throw OomphLibError("Plastic data index is too large",
113+
OOMPH_EXCEPTION_LOCATION,
114+
OOMPH_CURRENT_FUNCTION);
115+
}
116+
#endif
117+
Plastic_data_pinned_status[ipt][data_type][index] = true;
118+
}
119+
}
88120

89-
void resize_plastic_dof_numbers(const unsigned& nipt)
121+
void unpin_plastic_dof(const unsigned& ipt,
122+
const unsigned& data_type,
123+
const int& index = -1)
124+
{
125+
if (index < 0)
126+
{
127+
const unsigned nvalue =
128+
Plastic_data_pinned_status[ipt][data_type].size();
129+
for (unsigned i = 0; i < nvalue; i++)
130+
{
131+
Plastic_data_pinned_status[ipt][data_type][i] = false;
132+
}
133+
}
134+
else
135+
{
136+
#ifdef PARANOID
137+
// Check if the index makes sense
138+
if (index > Plastic_data_pinned_status[ipt][data_type].size() - 1)
139+
{
140+
throw OomphLibError("Plastic data index is too large",
141+
OOMPH_EXCEPTION_LOCATION,
142+
OOMPH_CURRENT_FUNCTION);
143+
}
144+
#endif
145+
Plastic_data_pinned_status[ipt][data_type][index] = false;
146+
}
147+
}
148+
149+
// Change to not have an argument - in fact if we're always building all
150+
// plastic data then we don't need thi Collapse all building plastic data
151+
// into a single function
152+
void resize_plastic_dof_numbers()
90153
{
91154
if (Plastic_dof_nunbers_has_been_resized) return;
92155

156+
const unsigned nipt = this->integral_pt()->nweight();
157+
93158
Plastic_data_pt.resize(nipt);
94159
Plastic_data_pinned_status.resize(nipt);
95160
Plastic_data_eqn_number.resize(nipt);
@@ -145,11 +210,10 @@ namespace oomph
145210
Plastic_data_has_been_built[invFp_INDEX] = true;
146211

147212
const unsigned nipt = this->integral_pt()->nweight();
148-
resize_plastic_dof_numbers(nipt);
149-
150213
for (unsigned ipt = 0; ipt < nipt; ipt++)
151214
{
152215
Data* data_pt = new Data(DIM * DIM);
216+
data_pt->time_stepper_pt() = &Default_plastic_timestepper;
153217
Plastic_data_pt[ipt][invFp_INDEX] = data_pt;
154218
(void)this->add_internal_data(data_pt, false);
155219
for (unsigned i = 0; i < DIM * DIM; i++)
@@ -176,10 +240,10 @@ namespace oomph
176240
if (Plastic_data_has_been_built[Fpks_INDEX]) return;
177241
Plastic_data_has_been_built[Fpks_INDEX] = true;
178242
const unsigned nipt = this->integral_pt()->nweight();
179-
resize_plastic_dof_numbers(nipt);
180243
for (unsigned ipt = 0; ipt < nipt; ipt++)
181244
{
182245
Data* data_pt = new Data(DIM * DIM);
246+
data_pt->time_stepper_pt() = &Default_plastic_timestepper;
183247
Plastic_data_pt[ipt][Fpks_INDEX] = data_pt;
184248
(void)this->add_internal_data(data_pt, false);
185249
for (unsigned i = 0; i < DIM * DIM; i++)
@@ -206,10 +270,10 @@ namespace oomph
206270
if (Plastic_data_has_been_built[Fpcs_INDEX]) return;
207271
Plastic_data_has_been_built[Fpcs_INDEX] = true;
208272
const unsigned nipt = this->integral_pt()->nweight();
209-
resize_plastic_dof_numbers(nipt);
210273
for (unsigned ipt = 0; ipt < nipt; ipt++)
211274
{
212275
Data* data_pt = new Data(DIM * DIM);
276+
data_pt->time_stepper_pt() = &Default_plastic_timestepper;
213277
Plastic_data_pt[ipt][Fpcs_INDEX] = data_pt;
214278
(void)this->add_internal_data(data_pt, false);
215279
for (unsigned i = 0; i < DIM * DIM; i++)
@@ -236,10 +300,10 @@ namespace oomph
236300
if (Plastic_data_has_been_built[H_INDEX]) return;
237301
Plastic_data_has_been_built[H_INDEX] = true;
238302
const unsigned nipt = this->integral_pt()->nweight();
239-
resize_plastic_dof_numbers(nipt);
240303
for (unsigned ipt = 0; ipt < nipt; ipt++)
241304
{
242305
Data* data_pt = new Data(1);
306+
data_pt->time_stepper_pt() = &Default_plastic_timestepper;
243307
Plastic_data_pt[ipt][H_INDEX] = data_pt;
244308
(void)this->add_internal_data(data_pt, false);
245309
// Pin the plastic degree of freedom
@@ -259,10 +323,10 @@ namespace oomph
259323
if (Plastic_data_has_been_built[R_INDEX]) return;
260324
Plastic_data_has_been_built[R_INDEX] = true;
261325
const unsigned nipt = this->integral_pt()->nweight();
262-
resize_plastic_dof_numbers(nipt);
263326
for (unsigned ipt = 0; ipt < nipt; ipt++)
264327
{
265328
Data* data_pt = new Data(1);
329+
data_pt->time_stepper_pt() = &Default_plastic_timestepper;
266330
Plastic_data_pt[ipt][R_INDEX] = data_pt;
267331
(void)this->add_internal_data(data_pt, false);
268332
// Pin the plastic degree of freedom
@@ -282,10 +346,10 @@ namespace oomph
282346
if (Plastic_data_has_been_built[Lambda_INDEX]) return;
283347
Plastic_data_has_been_built[Lambda_INDEX] = true;
284348
const unsigned nipt = this->integral_pt()->nweight();
285-
resize_plastic_dof_numbers(nipt);
286349
for (unsigned ipt = 0; ipt < nipt; ipt++)
287350
{
288351
Data* data_pt = new Data(1);
352+
data_pt->time_stepper_pt() = &Default_plastic_timestepper;
289353
Plastic_data_pt[ipt][Lambda_INDEX] = data_pt;
290354
(void)this->add_internal_data(data_pt, false);
291355
// Pin the plastic degree of freedom
@@ -299,6 +363,25 @@ namespace oomph
299363
}
300364
}
301365

366+
void construct_plastic_data()
367+
{
368+
resize_plastic_dof_numbers();
369+
370+
construct_inv_fp_internal_data();
371+
construct_fpks_internal_data();
372+
construct_fpcs_internal_data();
373+
construct_r_internal_data();
374+
construct_lambda_internal_data();
375+
376+
// No longer really neccesary
377+
construct_h_internal_data();
378+
379+
// We assign the equation numbers now because the user will likely want
380+
// all plastic data unpinned. If they pin any then they will need to call
381+
// assign_plastic_eqn_numbers again
382+
assign_plastic_eqn_numbers();
383+
}
384+
302385
unsigned plastic_inv_fp_eqn_number(const unsigned& ipt,
303386
const unsigned& i,
304387
const unsigned& j) const
@@ -1301,7 +1384,7 @@ namespace oomph
13011384
}
13021385
}
13031386

1304-
// Need to reassign eqn numbers, because pointers may have changed.
1387+
// Need to reassign eqn numbers because pointers may have changed.
13051388
assign_plastic_eqn_numbers();
13061389
}
13071390

@@ -1539,19 +1622,8 @@ namespace oomph
15391622
public:
15401623
QPlasticPVDElement() : SolidQElement<DIM, NNODE>(), PlasticEquations<DIM>()
15411624
{
1542-
// For our test case we assume no plastic core and no plastic kinematic
1543-
// dissipation so we don't construct those data
1544-
this->construct_inv_fp_internal_data();
1545-
this->construct_fpks_internal_data();
1546-
this->construct_fpcs_internal_data();
1547-
this->construct_r_internal_data();
1548-
this->construct_lambda_internal_data();
1549-
1550-
// No longer really neccesary
1551-
this->construct_h_internal_data();
1552-
1553-
// Assign the equation numbers
1554-
this->assign_plastic_eqn_numbers();
1625+
// Construct all plastic data
1626+
this->construct_plastic_data();
15551627
}
15561628

15571629
/// Output function

0 commit comments

Comments
 (0)