Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import normaopinf
import normaopinf.opinf
import nnopinf
import nnopinf.training
import os
import numpy as np

if __name__ == '__main__':
settings = {}
settings['fom-yaml-file'] = "cuboid-1.yaml"
settings['training-data-directories'] = [os.getcwd()]
settings['model-type'] = 'linear'
settings['stop-training-time'] = 'end'
settings['training-skip-steps'] = 1
settings['forcing'] = False
settings['truncation-type'] = 'energy'
settings['boundary-truncation-type'] = 'energy'
settings['regularization-parameter'] = 5.e-3
settings['trial-space-splitting-type'] = 'split'
settings['acceleration-computation-type'] = 'finite-difference'
snapshots_dict = normaopinf.opinf.get_processed_snapshots(settings)
settings['truncation-value'] = 1. - 1.e-5
settings['boundary-truncation-value'] = 1. - 1.e-5
settings['model-name'] = 'opinf-operator-1'
normaopinf.opinf.make_opinf_model_from_snapshots_dict(snapshots_dict,settings)

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import normaopinf
import normaopinf.opinf
import nnopinf
import nnopinf.training
import os
import numpy as np

if __name__ == '__main__':
settings = {}
settings['fom-yaml-file'] = "cuboid-2.yaml"
settings['training-data-directories'] = [os.getcwd()]
settings['model-type'] = 'linear'
settings['stop-training-time'] = 'end'
settings['training-skip-steps'] = 1
settings['forcing'] = False
settings['truncation-type'] = 'energy'
settings['boundary-truncation-type'] = 'energy'
settings['regularization-parameter'] = 5.e-3
settings['trial-space-splitting-type'] = 'split'
settings['acceleration-computation-type'] = 'finite-difference'
snapshots_dict = normaopinf.opinf.get_processed_snapshots(settings)
settings['truncation-value'] = 1. - 1.e-5
settings['boundary-truncation-value'] = 1. - 1.e-5
settings['model-name'] = 'opinf-operator-2'
normaopinf.opinf.make_opinf_model_from_snapshots_dict(snapshots_dict,settings)

Binary file not shown.
41 changes: 41 additions & 0 deletions examples/ahead/overlap/cuboid/dynamic-opinf-rom-rom/cuboid-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
type: single
input mesh file: cuboid-1.g
output mesh file: cuboid-1.e
model:
type: linear opinf rom
model-file: opinf-operator-1.npz
material:
blocks:
fine: hyperelastic
hyperelastic:
model: neohookean
elastic modulus: 1.0e+09
Poisson's ratio: 0.25
density: 1000.0
time integrator:
type: Newmark
β: 0.25
γ: 0.5
boundary conditions:
Dirichlet:
- node set: nsx-
component: x
function: "0.0"
- node set: nsy-
component: y
function: "0.0"
- node set: nsz-
component: z
function: "0.0"
Schwarz overlap:
- side set: ssz+
source: cuboid-2
source block: coarse
source side set: ssz-
solver:
type: Hessian minimizer
step: full Newton
minimum iterations: 1
maximum iterations: 16
relative tolerance: 1.0e-10
absolute tolerance: 1.0e-06
Binary file not shown.
35 changes: 35 additions & 0 deletions examples/ahead/overlap/cuboid/dynamic-opinf-rom-rom/cuboid-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
type: single
input mesh file: cuboid-2.g
output mesh file: cuboid-2.e
model:
type: linear opinf rom
model-file: opinf-operator-2.npz
material:
blocks:
coarse: hyperelastic
hyperelastic:
model: neohookean
elastic modulus: 1.0e+09
Poisson's ratio: 0.25
density: 1000.0
time integrator:
type: Newmark
β: 0.25
γ: 0.5
boundary conditions:
Dirichlet:
- node set: nsz+
component: z
function: "1.0 * t"
Schwarz overlap:
- side set: ssz-
source: cuboid-1
source block: fine
source side set: ssz+
solver:
type: Hessian minimizer
step: full Newton
minimum iterations: 1
maximum iterations: 16
relative tolerance: 1.0e-10
absolute tolerance: 1.0e-06
11 changes: 11 additions & 0 deletions examples/ahead/overlap/cuboid/dynamic-opinf-rom-rom/cuboids.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type: multi
domains: ["cuboid-1.yaml", "cuboid-2.yaml"]
Exodus output interval: 1
CSV output interval: 1
initial time: 0.0
final time: 0.1
time step: 0.01
minimum iterations: 1
maximum iterations: 16
relative tolerance: 1.0e-12
absolute tolerance: 1.0e-08
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion src/ics_bcs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ function apply_bc_detail(model::SolidMechanics, bc::SolidMechanicsNonOverlapSchw
end

function apply_bc_detail(model::OpInfModel, bc::SolidMechanicsCouplingSchwarzBoundaryCondition)
if bc.coupled_subsim.model isa SolidMechanics
if bc.coupled_subsim.model isa SolidMechanics || bc.coupled_subsim.model isa OpInfModel
## Apply BC to the FOM vector
apply_bc_detail(model.fom_model, bc)

Expand Down
34 changes: 34 additions & 0 deletions test/opinf-schwarz-overlap-rom-rom-cuboid-hex8.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Norma: Copyright 2025 National Technology & Engineering Solutions of
# Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS,
# the U.S. Government retains certain rights in this software. This software
# is released under the BSD license detailed in the file license.txt in the
# top-level Norma.jl directory.
@testset "Opinf Schwarz Overlap Dynamic Cuboid Hex8 Same Step" begin
cp("../examples/ahead/overlap/cuboid/dynamic-opinf-rom-rom/cuboid-1.yaml", "cuboid-1.yaml"; force=true)
cp("../examples/ahead/overlap/cuboid/dynamic-opinf-rom-rom/cuboid-2.yaml", "cuboid-2.yaml"; force=true)
cp("../examples/ahead/overlap/cuboid/dynamic-opinf-rom-rom/cuboids.yaml", "cuboids.yaml"; force=true)
cp("../examples/ahead/overlap/cuboid/dynamic-opinf-rom-rom/opinf-operator-1.npz", "opinf-operator-1.npz"; force=true)
cp("../examples/ahead/overlap/cuboid/dynamic-opinf-rom-rom/opinf-operator-2.npz", "opinf-operator-2.npz"; force=true)
cp("../examples/ahead/overlap/cuboid/dynamic-opinf-rom-rom/cuboid-1.g", "cuboid-1.g"; force=true)
cp("../examples/ahead/overlap/cuboid/dynamic-opinf-rom-rom/cuboid-2.g", "cuboid-2.g"; force=true)
sim = Norma.run("cuboids.yaml")
subsims = sim.subsims
model_fine = subsims[1].model
model_coarse = subsims[2].model
rm("cuboids.yaml")
rm("cuboid-1.yaml")
rm("cuboid-2.yaml")
rm("cuboid-1.g")
rm("cuboid-2.g")
rm("cuboid-1.e")
rm("cuboid-2.e")
rm("opinf-operator-1.npz")
rm("opinf-operator-2.npz")

@test model_coarse.reduced_state[1] ≈ -0.0008153342945627467 rtol = 1.0e-06
@test model_coarse.reduced_state[2] ≈ -0.0008153342949887136 rtol = 1.0e-06
@test model_coarse.reduced_state[3] ≈ 0.19986541967787202 rtol = 1.0e-06
@test model_fine.reduced_state[1] ≈ -0.0061291008333238 rtol = 1.0e-06
@test model_fine.reduced_state[2] ≈ -0.006129100833376133 rtol = 1.0e-06
@test model_fine.reduced_state[3] ≈ -0.34397149691049 rtol = 1.0e-06
end
41 changes: 21 additions & 20 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,28 @@ const indexed_test_files = [
(18, "schwarz-contact-dynamic-cubes.jl"),
(19, "solid-inclined-displacement.jl"),
(20, "opinf-schwarz-overlap-cuboid-hex8.jl"),
(21, "quadratic-opinf-schwarz-overlap-cuboid-hex8.jl"),
(22, "cubic-opinf-schwarz-overlap-cuboid-hex8.jl"),
(23, "adaptive-time-stepping.jl"),
(24, "schwarz-ahead-overlap-dynamic-clamped.jl"),
(25, "schwarz-ahead-overlap-dynamic-notched-cylinder.jl"),
(21, "opinf-schwarz-overlap-rom-rom-cuboid-hex8.jl"),
(22, "quadratic-opinf-schwarz-overlap-cuboid-hex8.jl"),
(23, "cubic-opinf-schwarz-overlap-cuboid-hex8.jl"),
(24, "adaptive-time-stepping.jl"),
(25, "schwarz-ahead-overlap-dynamic-clamped.jl"),
(26, "schwarz-ahead-overlap-dynamic-notched-cylinder.jl"),
(26, "schwarz-ahead-overlap-dynamic-laser-weld.jl"),
(27, "schwarz-ahead-overlap-dynamic-torsion.jl"),
(28, "schwarz-ahead-overlap-dynamic-bracket.jl"),
(29, "schwarz-ahead-overlap-dynamic-plate.jl"),
(30, "single-ahead-clamped.jl"),
(31, "single-ahead-notched-cylinder.jl"),
(32, "single-ahead-laser-weld.jl"),
(33, "single-ahead-torsion.jl"),
(34, "single-ahead-bracket.jl"),
(35, "single-ahead-plate.jl"),
(36, "schwarz-ahead-nonoverlap-dynamic-clamped.jl"),
(37, "schwarz-ahead-nonoverlap-dynamic-laser-weld.jl"),
(38, "schwarz-ahead-nonoverlap-dynamic-torsion.jl"),
(39, "schwarz-ahead-nonoverlap-dynamic-plate.jl"),
(40, "schwarz-ahead-nonoverlap-dynamic-bracket.jl"),
(41, "utils.jl"), # Must go last due to FPE traps
(28, "schwarz-ahead-overlap-dynamic-torsion.jl"),
(29, "schwarz-ahead-overlap-dynamic-bracket.jl"),
(30, "schwarz-ahead-overlap-dynamic-plate.jl"),
(31, "single-ahead-clamped.jl"),
(32, "single-ahead-notched-cylinder.jl"),
(33, "single-ahead-laser-weld.jl"),
(34, "single-ahead-torsion.jl"),
(35, "single-ahead-bracket.jl"),
(36, "single-ahead-plate.jl"),
(37, "schwarz-ahead-nonoverlap-dynamic-clamped.jl"),
(38, "schwarz-ahead-nonoverlap-dynamic-laser-weld.jl"),
(39, "schwarz-ahead-nonoverlap-dynamic-torsion.jl"),
(40, "schwarz-ahead-nonoverlap-dynamic-plate.jl"),
(41, "schwarz-ahead-nonoverlap-dynamic-bracket.jl"),
(42, "utils.jl"), # Must go last due to FPE traps
]

# Extract test file names
Expand Down
Loading