예제 #1
0
 def __init__(self, preciceConfigFile, participantName, config, MESH, MODEL, MAT, isNonLinear=False):
     self.interfaces = []
     self.numInterfaces = len(config)
     self.MESH = MESH
     self.MODEL = MODEL
     self.MAT = MAT
     self.LOADS = []
     self.isNonLinear = isNonLinear
     self.participantName = participantName
     self.preciceDt = -1
     self.precice = PySolverInterface(participantName, 0, 1)
     self.precice.configure(preciceConfigFile)
     self.configure(config)
예제 #2
0
                    type=str)
args = parser.parse_args()

style = config.style
configFileName = args.configurationFileName
N = config.n_elem
init_temp = config.init_temp
bound_temp = config.bound_temp
jump_temp = config.jump_temp
dt = config.dt
maxT = max(init_temp, bound_temp, jump_temp)

solverName = "TEMPRIGHT"

print "Configure preCICE..."
interface = PySolverInterface(solverName, 0, 1)
interface.configure(configFileName)

dimensions = interface.getDimensions()

rightNodes = (init_temp * np.ones((N - 1) * N)).reshape((N - 1), N)
rightNodes = np.pad(rightNodes, (1, 1),
                    'constant',
                    constant_values=(bound_temp, bound_temp))[0:N][:]
rightNodes_n = np.copy(rightNodes)

midNodes = np.copy(rightNodes[N - 1][:])
rightBound = np.copy(midNodes)

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
예제 #3
0
    args = parser.parse_args()
except SystemExit:
    print("")
    print("Usage: python ./solverdummy precice-config participant-name mesh-name")    
    quit()

configFileName = args.configurationFileName
participantName = args.participantName
meshName = args.meshName

N = 1

solverProcessIndex = 0
solverProcessSize = 1

interface = PySolverInterface(participantName, solverProcessIndex, solverProcessSize)
interface.configure(configFileName)
    
meshID = interface.getMeshID(meshName)

dimensions = interface.getDimensions()
vertex = np.zeros(dimensions)
dataIndices = np.zeros(N)

interface.setMeshVertices(meshID, N, vertex, dataIndices)

dt = interface.initialize()
    
while interface.isCouplingOngoing():
   
    if interface.isActionRequired(PyActionWriteIterationCheckpoint()):
    print("Try $python FluidSolver.py precice-config.xml")
    quit()

print "Starting Fluid Solver..."

configFileName = args.configurationFileName

N = config.n_elem
dx = config.L / N  # element length

print "N: " + str(N)

solverName = "FLUID"

print "Configure preCICE..."
interface = PySolverInterface(solverName, 0, 1)
interface.configure(configFileName)
print "preCICE configured..."

dimensions = interface.getDimensions()

velocity = config.velocity_in(0) * np.ones(N+1)
velocity_n = config.velocity_in(0) * np.ones(N+1)
pressure = config.p0 * np.ones(N+1)
pressure_n = config.p0 * np.ones(N+1)
crossSectionLength = config.a0 * np.ones(N+1)
crossSectionLength_n = config.a0 * np.ones(N+1)

plotting_mode = config.PlottingModes.VIDEO
output_mode = config.OutputModes.VTK
writeVideoToFile = False
예제 #5
0
parser.add_argument("N", help="Number of mesh elements, needs to be equal for fluid and structure solver.", type=int)
parser.add_argument("tau", help="Dimensionless time step size", type=float)
parser.add_argument("kappa", help="Dimensionless structural stiffness", type=float)
args = parser.parse_args()

configFileName = args.configurationFileName
N              = args.N
tau            = args.tau
kappa          = args.kappa

print "N: " + str(N) + " tau: " + str(tau) + " kappa: " + str(kappa)

solverName = "FLUID";

print "Configure preCICE..."
interface = PySolverInterface(solverName, 0, 1)
interface.configure(configFileName)
print "preCICE configured..."

dimensions = interface.getDimensions();

velocity               = [1.0 / (kappa * 1.0)] * (N+1) #Speed
velocity_n             = [1.0 / (kappa * 1.0)] * (N+1)
pressure               = [0.0001] * (N+1) #Pressure
pressure_n             = [0.0001] * (N+1)
crossSectionLength     = [1.0] * (N+1) #Cross-section length
crossSectionLength_n   = [1.0] * (N+1)

meshID = interface.getMeshID("Fluid_Nodes")
crossSectionLengthID = interface.getDataID("CrossSectionLength", meshID)
pressureID = interface.getDataID("Pressure", meshID)
예제 #6
0
class Adapter:

    def __init__(self, preciceConfigFile, participantName, config, MESH, MODEL, MAT, isNonLinear=False):
        self.interfaces = []
        self.numInterfaces = len(config)
        self.MESH = MESH
        self.MODEL = MODEL
        self.MAT = MAT
        self.LOADS = []
        self.isNonLinear = isNonLinear
        self.participantName = participantName
        self.preciceDt = -1
        self.precice = PySolverInterface(participantName, 0, 1)
        self.precice.configure(preciceConfigFile)
        self.configure(config)
    
    def configure(self, config):
        L = [None] * self.numInterfaces        # Loads
        SM = [None] * self.numInterfaces    # Shifted meshes
        for i in range(self.numInterfaces):
            # Shifted mesh (interface nodes displaced by a distance delta in the direction of the surface normal
            # towards the inside of the solid)
            SM[i] = CREA_MAILLAGE(MAILLAGE=self.MESH, RESTREINT={"GROUP_MA": config[i]["patch"], "GROUP_NO": config[i]["patch"]})
            # Create interface
            interface = Interface(self.precice, self.participantName, config[i], self.MESH, SM[i], self.MODEL, self.MAT[config[i]["material-id"]], self.isNonLinear)
            # Loads
            BCs = interface.createBCs()
            L[i] = AFFE_CHAR_THER(MODELE=self.MODEL, ECHANGE=BCs)
            interface.setLoad(L[i])
            self.LOADS.append({'CHARGE': L[i]})
            self.interfaces.append(interface)

    def initialize(self, INIT_T):

        self.preciceDt = self.precice.initialize()

        if self.precice.isActionRequired(PyActionWriteInitialData()):
            self.writeCouplingData(INIT_T)
            self.precice.fulfilledAction(PyActionWriteInitialData())

        self.precice.initializeData()

        return self.preciceDt

    def isCouplingOngoing(self):
        return self.precice.isCouplingOngoing()
    
    def writeCouplingData(self, TEMP):
        if self.precice.isWriteDataRequired(self.preciceDt):
            for interface in self.interfaces:
                interface.writeBCs(TEMP)
    
    def readCouplingData(self):
        if self.precice.isReadDataAvailable():
            for interface in self.interfaces:
                interface.readAndUpdateBCs()

    def writeCheckpoint(self):
        if self.precice.isActionRequired(PyActionWriteIterationCheckpoint()):
            # Do nothing
            self.precice.fulfilledAction(PyActionWriteIterationCheckpoint())

    def readCheckpoint(self):
        if self.precice.isActionRequired(PyActionReadIterationCheckpoint()):
            # Do nothing
            self.precice.fulfilledAction(PyActionReadIterationCheckpoint())

    def isCouplingTimestepComplete(self):
        return self.precice.isTimestepComplete()

    def advance(self):
        self.preciceDt = self.precice.advance(self.preciceDt)
        return self.preciceDt

    def finalize(self):
        self.precice.finalize()