DAFoamPropForce Class Reference
Inheritance diagram for DAFoamPropForce:
Inheritance graph
[legend]
Collaboration diagram for DAFoamPropForce:
Collaboration graph
[legend]

Detailed Description

DAFoam component that computes the propeller force and radius profile based on the CFD surface states
def initialize(self):
    self.options.declare("solver", recordable=False)

def setup(self):

    self.DASolver = self.options["solver"]

    self.discipline = self.DASolver.getOption("discipline")

    self.add_input("%s_states" % self.discipline, distributed=True, shape_by_conn=True, tags=["mphys_coupling"])
    self.add_input("%s_vol_coords" % self.discipline, distributed=True, shape_by_conn=True, tags=["mphys_coupling"])

    self.nForceSections = self.DASolver.getOption("wingProp")["nForceSections"]
    self.add_output("force_profile", distributed=False, shape=3 * self.nForceSections, tags=["mphys_coupling"])
    self.add_output("radial_location", distributed=False, shape=self.nForceSections, tags=["mphys_coupling"])

def compute(self, inputs, outputs):

    DASolver = self.DASolver

    dafoam_states = inputs["%s_states" % self.discipline]
    dafoam_xv = inputs["%s_vol_coords" % self.discipline]

    stateVec = DASolver.array2Vec(dafoam_states)
    xvVec = DASolver.array2Vec(dafoam_xv)

    fProfileVec = PETSc.Vec().createSeq(3 * self.nForceSections, bsize=1, comm=PETSc.COMM_SELF)
    fProfileVec.zeroEntries()

    sRadiusVec = PETSc.Vec().createSeq(self.nForceSections, bsize=1, comm=PETSc.COMM_SELF)
    sRadiusVec.zeroEntries()

    DASolver.solver.calcForceProfile(xvVec, stateVec, fProfileVec, sRadiusVec)

    outputs["force_profile"] = DASolver.vec2ArraySeq(fProfileVec)
    outputs["radial_location"] = DASolver.vec2ArraySeq(sRadiusVec)

def compute_jacvec_product(self, inputs, d_inputs, d_outputs, mode):
    DASolver = self.DASolver

    dafoam_states = inputs["%s_states" % self.discipline]
    dafoam_xv = inputs["%s_vol_coords" % self.discipline]

    stateVec = DASolver.array2Vec(dafoam_states)
    xvVec = DASolver.array2Vec(dafoam_xv)

    if mode == "fwd":
        raise AnalysisError("fwd not implemented!")

    if "force_profile" in d_outputs:
        fBar = d_outputs["force_profile"]
        fBarVec = DASolver.array2VecSeq(fBar)

        if "%s_states" % self.discipline in d_inputs:
            prodVec = self.DASolver.wVec.duplicate()
            prodVec.zeroEntries()
            DASolver.solverAD.calcdForcedStateTPsiAD("dFdW".encode(), xvVec, stateVec, fBarVec, prodVec)
            pBar = DASolver.vec2Array(prodVec)
            d_inputs["%s_states" % self.discipline] += pBar

        # xv has no contribution to the force profile
        if "%s_vol_coords" % self.discipline in d_inputs:
            prodVec = self.DASolver.xvVec.duplicate()
            prodVec.zeroEntries()
            pBar = DASolver.vec2Array(prodVec)
            d_inputs["%s_vol_coords" % self.discipline] += pBar

    if "radial_location" in d_outputs:
        rBar = d_outputs["radial_location"]
        rBarVec = DASolver.array2VecSeq(rBar)

        # states have no effect on the radius
        if "%s_states" % self.discipline in d_inputs:
            prodVec = self.DASolver.wVec.duplicate()
            prodVec.zeroEntries()
            pBar = DASolver.vec2Array(prodVec)
            d_inputs["%s_states" % self.discipline] += pBar

        if "%s_vol_coords" % self.discipline in d_inputs:
            prodVec = self.DASolver.xvVec.duplicate()
            DASolver.solverAD.calcdForcedStateTPsiAD("dRdX".encode(), xvVec, stateVec, rBarVec, prodVec)
            prodVec.zeroEntries()
            pBar = DASolver.vec2Array(prodVec)
            d_inputs["%s_vol_coords" % self.discipline] += pBar

Definition at line 1704 of file mphys_dafoam.py.


The documentation for this class was generated from the following file: