Skip to content

Add capability to write volume slices #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
43 changes: 37 additions & 6 deletions adflow/pyADflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@
v. 1.0 - Original pyAero Framework Implementation (RP,SM 2008)
"""

import copy
import hashlib
# =============================================================================
# Imports
# =============================================================================
import os
import sys
import time
import copy
import types
from collections import OrderedDict

import numpy
import sys
from baseclasses import AeroProblem, AeroSolver, getPy3SafeString
from baseclasses.utils import CaseInsensitiveDict, Error
from mpi4py import MPI
from baseclasses import AeroSolver, AeroProblem, getPy3SafeString
from baseclasses.utils import Error, CaseInsensitiveDict

from . import MExt
import hashlib
from collections import OrderedDict


class ADFLOWWarning(object):
Expand Down Expand Up @@ -3063,6 +3065,35 @@
f.close()
# end if (root proc )

def writeFamilySolution(self, familyName, outputDir=None, baseName=None, number=None):
if outputDir is None:
outputDir = self.getOption("outputDirectory")

Check warning on line 3070 in adflow/pyADflow.py

View check run for this annotation

Codecov / codecov/patch

adflow/pyADflow.py#L3069-L3070

Added lines #L3069 - L3070 were not covered by tests

if baseName is None:
baseName = self.curAP.name

Check warning on line 3073 in adflow/pyADflow.py

View check run for this annotation

Codecov / codecov/patch

adflow/pyADflow.py#L3072-L3073

Added lines #L3072 - L3073 were not covered by tests

if not familyName.lower() in self.families:
raise Error(f"Family {familyName} not found in the solver.")

Check warning on line 3076 in adflow/pyADflow.py

View check run for this annotation

Codecov / codecov/patch

adflow/pyADflow.py#L3075-L3076

Added lines #L3075 - L3076 were not covered by tests

famList = self._getFamilyList(familyName)
numDigits = self.getOption("writeSolutionDigits")
famID = self.families[familyName.lower()][0]
isBC = True if famID in self._getFamilyList("allSurfaces") else False

Check warning on line 3081 in adflow/pyADflow.py

View check run for this annotation

Codecov / codecov/patch

adflow/pyADflow.py#L3078-L3081

Added lines #L3078 - L3081 were not covered by tests

if number is not None:
baseName = f"{baseName}_{familyName.lower()}_{number:0{numDigits}d}"

Check warning on line 3084 in adflow/pyADflow.py

View check run for this annotation

Codecov / codecov/patch

adflow/pyADflow.py#L3083-L3084

Added lines #L3083 - L3084 were not covered by tests
else:
if self.getOption("numberSolutions"):
baseName = f"{baseName}_{familyName.lower()}_{self.curAP.adflowData.callCounter:0{numDigits}d}"

Check warning on line 3087 in adflow/pyADflow.py

View check run for this annotation

Codecov / codecov/patch

adflow/pyADflow.py#L3086-L3087

Added lines #L3086 - L3087 were not covered by tests

fileName = os.path.join(outputDir, baseName)
fileName += ".dat"

Check warning on line 3090 in adflow/pyADflow.py

View check run for this annotation

Codecov / codecov/patch

adflow/pyADflow.py#L3089-L3090

Added lines #L3089 - L3090 were not covered by tests

if isBC:
self.adflow.tecplotio.writebcsurfacesascii(fileName, famList)

Check warning on line 3093 in adflow/pyADflow.py

View check run for this annotation

Codecov / codecov/patch

adflow/pyADflow.py#L3092-L3093

Added lines #L3092 - L3093 were not covered by tests
else:
self.adflow.tecplotio.writeuserintsurf(familyName, fileName, famID)

Check warning on line 3095 in adflow/pyADflow.py

View check run for this annotation

Codecov / codecov/patch

adflow/pyADflow.py#L3095

Added line #L3095 was not covered by tests

def resetAdjoint(self, obj):
"""
Reset an adjoint 'obj' that is stored in the current
Expand Down
34 changes: 33 additions & 1 deletion src/f2py/adflow.pyf
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,41 @@ python module libadflow
integer(kind=inttype), optional,intent(in),check(len(famlist)>=nfamlist),depend(famlist) :: nfamlist=len(famlist)
end subroutine writetecplot

subroutine writebcsurfacesascii(filename,famlist) ! in output/tecplotIO.F90:tecplotio
use constants
use communication, only: myid,adflow_comm_world,nproc
use inputtimespectral, only: ntimeintervalsspectral
use inputphysics, only: equationmode
use inputiteration, only: printiterations
use inputio, only: precisionsurfgrid,precisionsurfsol
use outputmod, only: surfsolnames,numberofsurfsolvariables
use surfacefamilies, only: bcfamexchange,famnames,familyexchange
use utils, only: echk,setpointers,setbcpointers
use bcpointers, only: xx
use sorting, only: faminlist
use extraoutput, only: surfwriteblank
use oversetdata, only: zippermesh,zippermeshes
use surfaceutils
use petsc
character*(*) intent(in) :: filename
integer(kind=inttype) dimension(:),intent(in) :: famlist
end subroutine writebcsurfacesascii

subroutine initializeliftdistributiondata
end subroutine initializeliftdistributiondata

subroutine writeuserintsurf(slicename,filename,famid) ! in :test:tecplotIO.F90:tecplotio
use constants
use inputio
use commonformats, only: int5,sci6
use usersurfaceintegrationdata, only: userintsurfs,nuserintsurfs,userintsurf
use usersurfaceintegrations, only: getusersurfacedata
use sorting, only: faminlist
character*(*) intent(in) :: slicename
character*(*) intent(in) :: filename
integer(kind=inttype) intent(in) :: famid
end subroutine writeuserintsurf

end subroutine tecplotio

module surfaceintegrations
Expand All @@ -681,7 +714,6 @@ python module libadflow

subroutine interpolateintegrationsurfaces
end subroutine interpolateintegrationsurfaces

end module usersurfaceintegrations

module actuatorregion ! in :test:actuatorDiskRegion.F90
Expand Down
3 changes: 3 additions & 0 deletions src/modules/commonFormats.F90
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ module commonFormats
! Integers written with 5 characters
character(len=maxStringLen) :: int5 = '(*(I5))'

! Integers written with 7 characters
character(len=maxStringLen) :: int7 = '(*(I7))'

end module commonFormats
Loading
Loading