Skip to content

Commit

Permalink
added ex29p.py, regenerated all cxx
Browse files Browse the repository at this point in the history
  • Loading branch information
sshiraiwa committed Aug 8, 2021
1 parent 130267e commit 34e695a
Show file tree
Hide file tree
Showing 6 changed files with 394 additions and 21 deletions.
1 change: 1 addition & 0 deletions examples/ex27p.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
myid = MPI.COMM_WORLD.rank
smyid = '.'+'{:0>6d}'.format(myid)


def generate_serial_mesh(ref, a_):

mesh = mfem.Mesh(2, 29, 16, 24, 2)
Expand Down
35 changes: 20 additions & 15 deletions examples/ex28p.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
myid = MPI.COMM_WORLD.rank
smyid = '.'+'{:0>6d}'.format(myid)


def build_trapezoid_mesh(offset):
assert offset < 0.9, "offset is too large!"

Expand All @@ -40,10 +41,12 @@ def build_trapezoid_mesh(offset):

return mesh


def print0(*args):
if myid == 0:
print(*args)



def run(order=1,
offset=0.3,
reorder_space=True,
Expand All @@ -66,7 +69,7 @@ def run(order=1,

pmesh = mfem.ParMesh(MPI.COMM_WORLD, mesh)
pmesh.UniformRefinement()

# 4. Define a finite element space on the mesh. Here we use vector finite
# elements, i.e. dim copies of a scalar finite element space. The vector
# dimension is specified by the last argument of the FiniteElementSpace
Expand All @@ -78,9 +81,11 @@ def run(order=1,
else:
fec = mfem.H1_FECollection(order, dim)
if reorder_space:
fespace = mfem.ParFiniteElementSpace(pmesh, fec, dim, mfem.Ordering.byNODES)
fespace = mfem.ParFiniteElementSpace(
pmesh, fec, dim, mfem.Ordering.byNODES)
else:
fespace = mfem.ParFiniteElementSpace(pmesh, fec, dim, mfem.Ordering.byVDIM)
fespace = mfem.ParFiniteElementSpace(
pmesh, fec, dim, mfem.Ordering.byVDIM)

s = fespace.GlobalTrueVSize()
print0("Number of finite element unknowns: " + str(s))
Expand Down Expand Up @@ -149,16 +154,16 @@ def run(order=1,
constraint_atts = mfem.intArray([1, 4])
constraint_rowstarts = mfem.intArray()
local_constraints = mfem.ParBuildNormalConstraints(fespace,
constraint_atts,
constraint_rowstarts)
constraint_atts,
constraint_rowstarts)

# 11. Define and apply an iterative solver for the constrained system
# in saddle-point form with a Gauss-Seidel smoother for the
# displacement block.
if penalty == 0.0:
solver = mfem.EliminationCGSolver(A, local_constraints,
constraint_rowstarts, dim,
reorder_space)
constraint_rowstarts, dim,
reorder_space)
else:
solver = mfem.PenaltyPCGSolver(A, local_constraints, penalty,
dim, reorder_space)
Expand All @@ -175,7 +180,7 @@ def run(order=1,

if not use_nodal_space:
pmesh.SetNodalFESpace(fespace)

nodes = pmesh.GetNodes()
nodes += x

Expand Down Expand Up @@ -212,10 +217,10 @@ def run(order=1,
action='store', default=1, type=int,
help="Finite element order (polynomial degree)")
parser.add_argument('-nodes', '--by-nodes',
action='store_true',
action='store_true',
help="Use byNODES ordering of vector space")
parser.add_argument('-vdim', '--by-vdim',
action='store_true',
action='store_true',
help="Use byVDIM ordering of vector space")
parser.add_argument('-offset', '--offset',
action='store', default=0.3, type=float,
Expand All @@ -229,17 +234,17 @@ def run(order=1,
parser.add_argument('-p', '--penalty',
action='store', default=0.0, type=float,
help="Penalty parameter; 0 means use elemination solver")

args = parser.parse_args()

reorder_space = False
if args.by_nodes:
reorder_space = True
if args.by_vdim:
reorder_space = False
args.by_nodes = reorder_space
args.by_vdim = not reorder_space
args.by_nodes = reorder_space
args.by_vdim = not reorder_space

if myid == 0:
parser.print_options(args)

Expand Down
Loading

0 comments on commit 34e695a

Please sign in to comment.