Skip to content

Commit 65b61e9

Browse files
thomasthomas
authored andcommitted
formatting
1 parent ca54696 commit 65b61e9

File tree

7 files changed

+320
-357
lines changed

7 files changed

+320
-357
lines changed

edelweissmpm/constraints/particlelagrangianweakdirichlet.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,20 @@ def ParticleLagrangianWeakDirichletOnParticleSetFactory(
184184
if isinstance(vertexID, list):
185185
for vertIdx in vertexID:
186186
name = f"{baseName}_{i}_v{vertIdx}"
187-
constraint = ParticleLagrangianWeakDirichlet( name, p, field, prescribedStepDelta, model, location, faceID, vertIdx)
187+
constraint = ParticleLagrangianWeakDirichlet(
188+
name, p, field, prescribedStepDelta, model, location, faceID, vertIdx
189+
)
188190
constraints[name] = constraint
189191
else:
190192
name = f"{baseName}_{i}_v{vertexID}"
191-
constraint = ParticleLagrangianWeakDirichlet( name, p, field, prescribedStepDelta, model, location, faceID, vertexID)
193+
constraint = ParticleLagrangianWeakDirichlet(
194+
name, p, field, prescribedStepDelta, model, location, faceID, vertexID
195+
)
192196
constraints[name] = constraint
193197
else:
194198
name = f"{baseName}_{i}"
195-
constraint = ParticleLagrangianWeakDirichlet( name, p, field, prescribedStepDelta, model, location, faceID, vertexID)
199+
constraint = ParticleLagrangianWeakDirichlet(
200+
name, p, field, prescribedStepDelta, model, location, faceID, vertexID
201+
)
196202
constraints[name] = constraint
197203
return constraints

edelweissmpm/generators/abqinpfilegenerator.py

Lines changed: 96 additions & 77 deletions
Large diffs are not rendered by default.

examples/124_abq_input_reader_test/abq_input_reader.py

Lines changed: 97 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,24 @@
2626
# ---------------------------------------------------------------------
2727

2828
import argparse
29-
#import gstools
3029

3130
import edelweissfe.utils.performancetiming as performancetiming
3231
import numpy as np
3332
import pytest
3433
from edelweissfe.journal.journal import Journal
3534
from edelweissfe.linsolve.pardiso.pardiso import pardisoSolve
3635
from edelweissfe.timesteppers.adaptivetimestepper import AdaptiveTimeStepper
37-
from edelweissfe.utils.exceptions import StepFailed
3836

3937
from edelweissmpm.constraints.particlelagrangianweakdirichlet import (
4038
ParticleLagrangianWeakDirichletOnParticleSetFactory,
4139
)
4240
from edelweissmpm.fieldoutput.fieldoutput import MPMFieldOutputController
43-
4441
from edelweissmpm.generators.abqinpfilegenerator import (
4542
generateKernelFunctionGridFromInputFile,
4643
)
4744
from edelweissmpm.meshfree.approximations.marmot.marmotmeshfreeapproximation import (
4845
MarmotMeshfreeApproximationWrapper,
4946
)
50-
from edelweissmpm.meshfree.kernelfunctions.marmot.marmotmeshfreekernelfunction import (
51-
MarmotMeshfreeKernelFunctionWrapper,
52-
)
5347
from edelweissmpm.meshfree.particlekerneldomain import ParticleKernelDomain
5448
from edelweissmpm.models.mpmmodel import MPMModel
5549
from edelweissmpm.outputmanagers.ensight import OutputManager as EnsightOutputManager
@@ -58,16 +52,21 @@
5852
)
5953
from edelweissmpm.particles.marmot.marmotparticlewrapper import MarmotParticleWrapper
6054
from edelweissmpm.solvers.nqs import NonlinearQuasistaticSolver
61-
#from edelweissmpm.solvers.nqsmparclength import NonlinearQuasistaticMarmotArcLengthSolver
62-
6355
from edelweissmpm.stepactions.particledistributedload import ParticleDistributedLoad
64-
from edelweissmpm.stepactions.particleindirectcontrol import IndirectControl
6556

66-
def run_sim(inputFilePath = "test_potato.inp",
67-
name="potato",
68-
supportRadiusFactor=1.1,
69-
outputName="_potato",
70-
particleType="GradientEnhancedMicropolarSQCNIxSDI/PlaneStrain/Quad"):
57+
# import gstools
58+
59+
60+
# from edelweissmpm.solvers.nqsmparclength import NonlinearQuasistaticMarmotArcLengthSolver
61+
62+
63+
def run_sim(
64+
inputFilePath="test_potato.inp",
65+
name="potato",
66+
supportRadiusFactor=1.1,
67+
outputName="_potato",
68+
particleType="GradientEnhancedMicropolarSQCNIxSDI/PlaneStrain/Quad",
69+
):
7170
dimension = 2
7271

7372
# set nump linewidth to 200:
@@ -81,24 +80,28 @@ def run_sim(inputFilePath = "test_potato.inp",
8180

8281
theModel = MPMModel(dimension)
8382

84-
kernelFunctionSpecifier={"kernelFunction": "BSplineBoxed", "continuityOrder": 3, "supportRadiusFactor": supportRadiusFactor}
83+
kernelFunctionSpecifier = {
84+
"kernelFunction": "BSplineBoxed",
85+
"continuityOrder": 3,
86+
"supportRadiusFactor": supportRadiusFactor,
87+
}
8588

8689
theApproximation = MarmotMeshfreeApproximationWrapper(
8790
"ReproducingKernelImplicitGradient", dimension, completenessOrder=1
8891
)
8992

90-
#=====================================================================
93+
# =====================================================================
9194
# MATERIAL
92-
#=====================================================================
95+
# =====================================================================
9396
theMaterial = {
9497
"material": "GMDamagedShearNeoHooke",
9598
# E, nu, GcToG, lb, lt, polarRatio
9699
"properties": np.array([4.5e3, 0.2, 1, 1, 1, 1.4999, 1.0]),
97100
}
98-
99-
#=====================================================================
101+
102+
# =====================================================================
100103
# PARTICLE FACTORY & MODEL
101-
#=====================================================================
104+
# =====================================================================
102105

103106
def TheParticleFactory(number, vertexCoordinates, volume):
104107
return MarmotParticleWrapper(
@@ -110,26 +113,28 @@ def TheParticleFactory(number, vertexCoordinates, volume):
110113
theMaterial,
111114
)
112115

113-
theModel = generateKernelFunctionGridFromInputFile(inputFilePath=inputFilePath,
114-
journal=theJournal,
115-
model=theModel,
116-
kernelFunctionSpecifier=kernelFunctionSpecifier,
117-
particleFactoryCallback=TheParticleFactory,
118-
firstKernelFunctionNumber=1,
119-
firstParticleNumber=1,
120-
name=name)
116+
theModel = generateKernelFunctionGridFromInputFile(
117+
inputFilePath=inputFilePath,
118+
journal=theJournal,
119+
model=theModel,
120+
kernelFunctionSpecifier=kernelFunctionSpecifier,
121+
particleFactoryCallback=TheParticleFactory,
122+
firstKernelFunctionNumber=1,
123+
firstParticleNumber=1,
124+
name=name,
125+
)
121126

122-
#=====================================================================
127+
# =====================================================================
123128
# SET PARTICLE PROPERTIES
124-
#=====================================================================
129+
# =====================================================================
125130

126131
for particle in theModel.particles.values():
127-
particle.setProperty("newmark-beta beta", 0.0 )
128-
particle.setProperty("newmark-beta gamma", 0.0 )
129-
particle.setProperty("VCI order", 0 )
132+
particle.setProperty("newmark-beta beta", 0.0)
133+
particle.setProperty("newmark-beta gamma", 0.0)
134+
particle.setProperty("VCI order", 0)
130135

131136
if "NSNI" in particleType:
132-
particle.setProperty("stabilize angular momentum", 1.0 )
137+
particle.setProperty("stabilize angular momentum", 1.0)
133138

134139
# let's create the particle kernel domain
135140
theParticleKernelDomain = ParticleKernelDomain(
@@ -148,31 +153,35 @@ def TheParticleFactory(number, vertexCoordinates, volume):
148153
# We need this model to create the dof manager
149154
theModel.particleKernelDomains["my_all_with_all"] = theParticleKernelDomain
150155

151-
#=====================================================================
156+
# =====================================================================
152157
# SET DIRICHLET BCs
153-
#=====================================================================
154-
155-
dirichletLeftBottom = ParticleLagrangianWeakDirichletOnParticleSetFactory("leftBottom",
156-
theModel.particleSets[f"{name}_b_leftBottom"],
157-
"displacement",
158-
{0: 0, 1: 0},
159-
theModel,
160-
location="center")
161-
dirichletRightBottom = ParticleLagrangianWeakDirichletOnParticleSetFactory("rightBottom",
162-
theModel.particleSets[f"{name}_b_rightBottom"],
163-
"displacement",
164-
{0: 0, 1: 0},
165-
theModel,
166-
location="center")
158+
# =====================================================================
159+
160+
dirichletLeftBottom = ParticleLagrangianWeakDirichletOnParticleSetFactory(
161+
"leftBottom",
162+
theModel.particleSets[f"{name}_b_leftBottom"],
163+
"displacement",
164+
{0: 0, 1: 0},
165+
theModel,
166+
location="center",
167+
)
168+
dirichletRightBottom = ParticleLagrangianWeakDirichletOnParticleSetFactory(
169+
"rightBottom",
170+
theModel.particleSets[f"{name}_b_rightBottom"],
171+
"displacement",
172+
{0: 0, 1: 0},
173+
theModel,
174+
location="center",
175+
)
167176
theModel.constraints.update(dirichletLeftBottom)
168177
theModel.constraints.update(dirichletRightBottom)
169178
theModel.prepareYourself(theJournal)
170179

171180
theJournal.printPrettyTable(theModel.makePrettyTableSummary(), "summary")
172181

173-
#=====================================================================
182+
# =====================================================================
174183
# SET FIELD OUTPUT
175-
#=====================================================================
184+
# =====================================================================
176185

177186
fieldOutputController = MPMFieldOutputController(theModel, theJournal)
178187

@@ -202,12 +211,12 @@ def TheParticleFactory(number, vertexCoordinates, volume):
202211
theModel.particleSets["all"],
203212
"microrotation",
204213
)
205-
214+
206215
fieldOutputController.initializeJob()
207216

208-
#=====================================================================
217+
# =====================================================================
209218
# ENSIGHT OUTPUT
210-
#=====================================================================
219+
# =====================================================================
211220

212221
ensightOutput = EnsightOutputManager(outputName, theModel, fieldOutputController, theJournal, None)
213222
ensightOutput.updateDefinition(fieldOutput=fieldOutputController.fieldOutputs["displacement"], create="perElement")
@@ -218,26 +227,24 @@ def TheParticleFactory(number, vertexCoordinates, volume):
218227
ensightOutput.updateDefinition(
219228
fieldOutput=fieldOutputController.fieldOutputs["deformation gradient"], create="perElement"
220229
)
221-
ensightOutput.updateDefinition(
222-
fieldOutput=fieldOutputController.fieldOutputs["stress"], create="perElement"
223-
)
224-
ensightOutput.updateDefinition(
225-
fieldOutput=fieldOutputController.fieldOutputs["microrotation"], create="perElement"
226-
)
230+
ensightOutput.updateDefinition(fieldOutput=fieldOutputController.fieldOutputs["stress"], create="perElement")
231+
ensightOutput.updateDefinition(fieldOutput=fieldOutputController.fieldOutputs["microrotation"], create="perElement")
227232
ensightOutput.initializeJob()
228233

229-
#=====================================================================
234+
# =====================================================================
230235
# SOLVER SETUP
231-
#=====================================================================
236+
# =====================================================================
232237

233238
incSize = 1
234-
adaptiveTimeStepper = AdaptiveTimeStepper(currentTime = theModel.time,
235-
stepLength = 1,
236-
startIncrement = incSize,
237-
maxIncrement = incSize,
238-
minIncrement = incSize / 1,
239-
maxNumberIncrements = 5000,
240-
journal = theJournal)
239+
adaptiveTimeStepper = AdaptiveTimeStepper(
240+
currentTime=theModel.time,
241+
stepLength=1,
242+
startIncrement=incSize,
243+
maxIncrement=incSize,
244+
minIncrement=incSize / 1,
245+
maxNumberIncrements=5000,
246+
journal=theJournal,
247+
)
241248

242249
nonlinearSolver = NonlinearQuasistaticSolver(theJournal)
243250
iterationOptions = nonlinearSolver.validOptions.copy()
@@ -259,18 +266,16 @@ def TheParticleFactory(number, vertexCoordinates, volume):
259266
iterationOptions["spec. relative field correction tolerances"]["micro rotation"] = 1e10
260267
iterationOptions["spec. absolute field correction tolerances"]["micro rotation"] = 1e10
261268

262-
263-
264269
linearSolver = pardisoSolve
265270

266271
from edelweissmpm.meshfree.vci import (
267272
BoundaryParticleDefinition,
268273
VariationallyConsistentIntegrationManager,
269274
)
270275

271-
#=====================================================================
276+
# =====================================================================
272277
# VCI SETUP
273-
#=====================================================================
278+
# =====================================================================
274279

275280
theBoundary = [
276281
BoundaryParticleDefinition(theModel.particleSets[f"{name}__s_wholeBoundary_S1"], np.empty(2), 1),
@@ -283,34 +288,34 @@ def TheParticleFactory(number, vertexCoordinates, volume):
283288
list(theModel.particles.values()), list(theModel.meshfreeKernelFunctions.values()), theBoundary
284289
)
285290

286-
#=====================================================================
291+
# =====================================================================
287292
# DISTRIBUTED LOADS
288-
#=====================================================================
293+
# =====================================================================
289294

290295
pressure_S1 = ParticleDistributedLoad(
291-
name = "pressure_S1",
292-
model = theModel,
293-
journal = theJournal,
294-
particles = theModel.particleSets[f"{name}__s_top_S1"],
295-
distributedLoadType = "pressure",
296-
loadVector = np.array([-10]),
296+
name="pressure_S1",
297+
model=theModel,
298+
journal=theJournal,
299+
particles=theModel.particleSets[f"{name}__s_top_S1"],
300+
distributedLoadType="pressure",
301+
loadVector=np.array([-10]),
297302
surfaceID=1,
298-
f_t=lambda t: t
303+
f_t=lambda t: t,
299304
)
300305
pressure_S3 = ParticleDistributedLoad(
301-
name = "pressure_S3",
302-
model = theModel,
303-
journal = theJournal,
304-
particles = theModel.particleSets[f"{name}__s_top_S3"],
305-
distributedLoadType = "pressure",
306-
loadVector = np.array([-10]),
306+
name="pressure_S3",
307+
model=theModel,
308+
journal=theJournal,
309+
particles=theModel.particleSets[f"{name}__s_top_S3"],
310+
distributedLoadType="pressure",
311+
loadVector=np.array([-10]),
307312
surfaceID=3,
308-
f_t=lambda t: t
313+
f_t=lambda t: t,
309314
)
310-
311-
#=====================================================================
315+
316+
# =====================================================================
312317
# SOLVE STEPS
313-
#=====================================================================
318+
# =====================================================================
314319

315320
try:
316321
theJournal.printSeperationLine()

examples/124_abq_input_reader_test/test_potato.inp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,19 +404,19 @@ _s_wholeBoundary_S1, S1
404404
*Solid Section, elset=all, material=material
405405
1.,
406406
*End Part
407-
**
407+
**
408408
**
409409
** ASSEMBLY
410410
**
411411
*Assembly, name=Assembly
412-
**
412+
**
413413
*Instance, name=potato-1, part=potato
414414
*End Instance
415-
**
415+
**
416416
*End Assembly
417-
**
417+
**
418418
** MATERIALS
419-
**
419+
**
420420
*Material, name=material
421421
*Elastic
422422
210000., 0.3

0 commit comments

Comments
 (0)