Skip to content

Commit

Permalink
Remove application of BCs from addSVSens entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
A-CGray committed Nov 1, 2024
1 parent 6efe6ff commit e9bc896
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
6 changes: 1 addition & 5 deletions src/TACSAssembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4909,8 +4909,7 @@ void TACSAssembler::addXptSens(TacsScalar coef, int numFuncs,
*/
void TACSAssembler::addSVSens(TacsScalar alpha, TacsScalar beta,
TacsScalar gamma, int numFuncs,
TACSFunction **funcs, TACSBVec **dfdu,
const bool applyBCs) {
TACSFunction **funcs, TACSBVec **dfdu) {
// First check if this is the right assembly object
for (int k = 0; k < numFuncs; k++) {
if (funcs[k] && this != funcs[k]->getAssembler()) {
Expand Down Expand Up @@ -4978,9 +4977,6 @@ void TACSAssembler::addSVSens(TacsScalar alpha, TacsScalar beta,
for (int k = 0; k < numFuncs; k++) {
if (funcs[k]) {
dfdu[k]->endSetValues(TACS_ADD_VALUES);
if (applyBCs) {
dfdu[k]->applyBCs(bcMap);
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/TACSAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ class TACSAssembler : public TACSObject {
void addDVSens(TacsScalar coef, int numFuncs, TACSFunction **funcs,
TACSBVec **dfdx);
void addSVSens(TacsScalar alpha, TacsScalar beta, TacsScalar gamma,
int numFuncs, TACSFunction **funcs, TACSBVec **dfdu,
const bool applyBCs = true);
int numFuncs, TACSFunction **funcs, TACSBVec **dfdu);
void addAdjointResProducts(TacsScalar scale, int numAdjoints,
TACSBVec **adjoint, TACSBVec **dfdx,
const TacsScalar lambda = 1.0);
Expand Down
4 changes: 2 additions & 2 deletions tacs/TACS.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2286,7 +2286,7 @@ cdef class Assembler:
return

def addSVSens(self, funclist, dfdulist, double alpha=1.0,
double beta=0.0, double gamma=0.0, bool applyBCs=True):
double beta=0.0, double gamma=0.0):

"""
Evaluate the derivative of the function w.r.t. the state
Expand Down Expand Up @@ -2316,7 +2316,7 @@ cdef class Assembler:
dfdu[i] = (<Vec>dfdulist[i]).getBVecPtr()

# Evaluate the derivative of the functions
self.ptr.addSVSens(alpha, beta, gamma, num_funcs, funcs, dfdu, applyBCs)
self.ptr.addSVSens(alpha, beta, gamma, num_funcs, funcs, dfdu)

free(funcs)
free(dfdu)
Expand Down
2 changes: 1 addition & 1 deletion tacs/cpp_headers/TACS.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ cdef extern from "TACSAssembler.h":
TACSBVec **dfdx)
void addSVSens(double alpha, double beta, double gamma,
int numFuncs, TACSFunction **funcs,
TACSBVec **fuSens, bool applyBCs)
TACSBVec **fuSens)
void addAdjointResProducts(double scale, int numAdjoints,
TACSBVec **adjoint, TACSBVec **dfdx,
TacsScalar loadScale)
Expand Down
6 changes: 3 additions & 3 deletions tacs/problems/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ def evalFunctionsSens(self, funcsSens, evalFuncs=None):

# Next we will solve all the adjoints
# Set adjoint rhs
self.addSVSens(evalFuncs, dIdus, applyBCs=False)
self.addSVSens(evalFuncs, dIdus)
adjointRHSTime = time.time()
for i, f in enumerate(evalFuncs):
adjointStartTime[f] = time.time()
Expand Down Expand Up @@ -1288,7 +1288,7 @@ def evalFunctionsSens(self, funcsSens, evalFuncs=None):
)
self._pp("+--------------------------------------------------+")

def addSVSens(self, evalFuncs, svSensList, applyBCs=False):
def addSVSens(self, evalFuncs, svSensList):
"""
Add the state variable partial sensitivity to the ADjoint RHS for given evalFuncs
Expand Down Expand Up @@ -1318,7 +1318,7 @@ def addSVSens(self, evalFuncs, svSensList, applyBCs=False):
svSensBVecList = svSensList

self.assembler.addSVSens(
funcHandles, svSensBVecList, self.alpha, self.beta, self.gamma, applyBCs
funcHandles, svSensBVecList, self.alpha, self.beta, self.gamma
)

# Update from the BVec values, if the input was a numpy array
Expand Down

0 comments on commit e9bc896

Please sign in to comment.