From 8f6483fdb83b46d5af695fddf1a7a5fb2c77c546 Mon Sep 17 00:00:00 2001 From: Petr Krysl Date: Tue, 14 Mar 2023 09:58:08 -0700 Subject: [PATCH] make initialization optional --- Project.toml | 2 +- src/AssemblyModule.jl | 51 ++++++++++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/Project.toml b/Project.toml index 974d052a..543c9a5d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "FinEtools" uuid = "91bb5406-6c9a-523d-811d-0644c4229550" authors = ["Petr Krysl "] -version = "6.0.8" +version = "6.0.9" [deps] ChunkSplitters = "ae650224-84b6-46f8-82ea-d812ca08434e" diff --git a/src/AssemblyModule.jl b/src/AssemblyModule.jl index 0f95e6f3..2a63e486 100644 --- a/src/AssemblyModule.jl +++ b/src/AssemblyModule.jl @@ -141,21 +141,26 @@ function startassembly!( elem_mat_ncols, elem_mat_nmatrices, ndofs_row, - ndofs_col, + ndofs_col; + force_init = false ) - # Only reset the buffers if the pointer is less than 1 + # Only resize the buffers if the pointer is less than 1 if self.buffer_pointer < 1 self.buffer_length = elem_mat_nmatrices * elem_mat_nrows * elem_mat_ncols resize!(self.rowbuffer, self.buffer_length) resize!(self.colbuffer, self.buffer_length) resize!(self.matbuffer, self.buffer_length) - self.rowbuffer .= 1 - self.colbuffer .= 1 - self.matbuffer .= 0 self.buffer_pointer = 1 self.ndofs_row = ndofs_row self.ndofs_col = ndofs_col end + # Leave the buffers uninitialized, unless the user requests otherwise + if force_init + self.rowbuffer .= 1 + self.colbuffer .= 1 + self.matbuffer .= 0 + end + return self end @@ -326,19 +331,23 @@ function startassembly!( ignore1, elem_mat_nmatrices, ndofs, - ignore2, + ignore2; + force_init = false ) - # Only reset the buffers if the pointer is less than 1 + # Only resize the buffers if the pointer is less than 1 if self.buffer_pointer < 1 self.buffer_length = elem_mat_nmatrices * elem_mat_dim^2 resize!(self.rowbuffer, self.buffer_length) resize!(self.colbuffer, self.buffer_length) resize!(self.matbuffer, self.buffer_length) + self.buffer_pointer = 1 + self.ndofs = ndofs + end + # Leave the buffers uninitialized, unless the user requests otherwise + if force_init self.rowbuffer .= 1 self.colbuffer .= 1 self.matbuffer .= 0 - self.buffer_pointer = 1 - self.ndofs = ndofs end return self end @@ -488,19 +497,23 @@ function startassembly!( ignore1, elem_mat_nmatrices, ndofs, - ignore2, + ignore2; + force_init = false ) - # Only reset the buffers if the pointer is less than 1 + # Only resize the buffers if the pointer is less than 1 if self.buffer_pointer < 1 self.buffer_length = elem_mat_nmatrices * elem_mat_dim + 1 resize!(self.rowbuffer, self.buffer_length) resize!(self.colbuffer, self.buffer_length) resize!(self.matbuffer, self.buffer_length) + self.buffer_pointer = 1 + self.ndofs = ndofs + end + # Leave the buffers uninitialized, unless the user requests otherwise + if force_init self.rowbuffer .= 1 self.colbuffer .= 1 self.matbuffer .= 0 - self.buffer_pointer = 1 - self.ndofs = ndofs end return self end @@ -777,19 +790,23 @@ function startassembly!( ignore1, elem_mat_nmatrices, ndofs, - ignore2, + ignore2; + force_init = false ) - # Only reset the buffers if the pointer is less than 1 + # Only resize the buffers if the pointer is less than 1 if self.buffer_pointer < 1 self.buffer_length = elem_mat_nmatrices * elem_mat_dim^2 resize!(self.rowbuffer, self.buffer_length) resize!(self.colbuffer, self.buffer_length) resize!(self.matbuffer, self.buffer_length) + self.buffer_pointer = 1 + self.ndofs = ndofs + end + # Leave the buffers uninitialized, unless the user requests otherwise + if force_init self.rowbuffer .= 1 self.colbuffer .= 1 self.matbuffer .= 0 - self.buffer_pointer = 1 - self.ndofs = ndofs end return self end