Skip to content

Commit 1bc92ee

Browse files
author
shiyi
committed
Bug fix: set_bc_dir() needed the current solution arrays (solutions.current.A/Y/D) to be allocated and initialized before it was called
1 parent 2c0069f commit 1bc92ee

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

Code/Source/solver/Integrator.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,12 @@ void Integrator::initialize_arrays() {
5050
Ag_.resize(tDof, tnNo);
5151
Yg_.resize(tDof, tnNo);
5252
Dg_.resize(tDof, tnNo);
53-
solutions_.current.A.resize(tDof, tnNo);
54-
solutions_.current.D.resize(tDof, tnNo);
55-
solutions_.current.Y.resize(tDof, tnNo);
5653
res_.resize(nFacesLS);
5754
incL_.resize(nFacesLS);
5855

59-
// old solution already initialized via move in constructor
60-
// Initialize current solution from old solution
61-
solutions_.current.A = solutions_.old.A;
62-
solutions_.current.D = solutions_.old.D;
63-
solutions_.current.Y = solutions_.old.Y;
56+
// Solution arrays (old and current) are already initialized in initialize()
57+
// and boundary conditions have been applied via set_bc_dir()
58+
// Do NOT reinitialize them here to preserve those boundary values
6459
}
6560

6661
//------------------------

Code/Source/solver/initialize.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,12 @@ void initialize(Simulation* simulation, Vector<double>& timeP)
643643
solutions.current.Y.resize(tDof, tnNo);
644644
solutions.current.D.resize(tDof, tnNo);
645645

646+
// Initialize current solution from old solution
647+
// (will be modified by set_bc_dir later, before Integrator creation)
648+
solutions.current.A = solutions.old.A;
649+
solutions.current.Y = solutions.old.Y;
650+
solutions.current.D = solutions.old.D;
651+
646652
com_mod.Bf.resize(nsd,tnNo);
647653

648654
// [TODO] DaveP not implemented?
@@ -770,8 +776,9 @@ void initialize(Simulation* simulation, Vector<double>& timeP)
770776
rmsh.D0 = solutions.old.D;
771777
} // resetSim
772778

773-
// Initialize new variables
774-
// An, Yn, Dn moved to Integrator class (initialized there from Ao, Yo, Do)
779+
// An, Yn, Dn are now part of SolutionStates struct (solutions.current)
780+
// They are initialized from Ao, Yo, Do earlier in this function
781+
// and will be modified by set_bc_dir() before being passed to Integrator
775782

776783
for (int iM = 0; iM < nMsh; iM++) {
777784
if (cm.mas(cm_mod)) {
@@ -840,13 +847,13 @@ void initialize(Simulation* simulation, Vector<double>& timeP)
840847
post::ppbin2vtk(simulation);
841848
}
842849

843-
// Making sure the old solution satisfies BCs
850+
// Making sure the solution satisfies BCs
844851
//
845-
// Modifies Ao, Yo, Do (via solutions struct)
852+
// Modifies both old (Ao, Yo, Do) and current (An, Yn, Dn) solution arrays
846853
//
847854
set_bc::set_bc_dir(com_mod, solutions);
848855

849-
// Preparing TXT files (pass solutions since An, Dn, and Yn haven't been created in Integrator yet)
856+
// Preparing TXT files
850857
txt_ns::txt(simulation, true, solutions);
851858

852859
// Printing the first line and initializing timeP

0 commit comments

Comments
 (0)