Example #1
0
def BenchmarkCheck(time, model_part):
    outlet_node = model_part.Nodes[2215]

    benchmarking.Output(time, "Time")

    benchmarking.Output(outlet_node.GetSolutionStepValue(DISTANCE),
                        "distance on node 2215 ", None, 0.01)
Example #2
0
def BenchmarkCheck(time, node1, node2):
    benchmarking.Output(time, "Time")
    # print "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII"
    benchmarking.Output(node1.GetSolutionStepValue(VELOCITY_X),
                        "Node 1 velocity_x", 0.01, .00001)
    benchmarking.Output(node2.GetSolutionStepValue(VELOCITY_X),
                        "Node 2 velocity_x", 0.01, .00001)
Example #3
0
def BenchmarkCheck(time, node1):
    benchmarking.Output(time, "Time", 0.0001, 0.0001)
    # print "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII"
    benchmarking.Output(node1.GetSolutionStepValue(PRESSURE),
                        "Node 1 pressure", 0.01, .00001)
    benchmarking.Output(node1.GetSolutionStepValue(VELOCITY_Y),
                        "Node 2 velocity_y", 0.01, .00001)
Example #4
0
def PrintDrag(drag_list, drag_file_output_list, fluid_model_part, time):
    i = 0
    for it in drag_list:
        print(it[0])
        nodes = fluid_model_part.GetNodes(it[0])
        drag = Vector(3);
        drag[0] = 0.0
        drag[1] = 0.0
        drag[2] = 0.0
        for node in nodes:
            reaction = node.GetSolutionStepValue(REACTION, 0)
            drag[0] += reaction[0]
            drag[1] += reaction[1]
            drag[2] += reaction[2]

        if (benchmarking.InBenchmarkingMode()):
            benchmarking.Output(drag[0], "drag X", 1e-9, 1e-3)
            benchmarking.Output(drag[1], "drag Y", 1e-9, 1e-3)
            benchmarking.Output(drag[2], "drag Z", 1e-9, 1e-3)

        output = str(time) + " " + str(drag[0]) + " " + str(drag[1]) + " " + str(drag[2]) + "\n"
        # print drag_file_output_list[i]
        # print output
        drag_file_output_list[i].write(output)
        drag_file_output_list[i].flush()
        i = i + 1
Example #5
0
def BenchmarkCheck(time, model_part):
    # find the largest displacement
    local_max_disp = 0.0
    for node in model_part.Nodes:
        disp = node.GetSolutionStepValue(DISPLACEMENT, 0)
        disp_value = disp[0] ** 2 + disp[1] ** 2 + disp[2] ** 2
        if(disp_value > local_max_disp):
            local_max_disp = disp_value

    max_values = mpi.gather(mpi.world, local_max_disp, 0)  # all_gather would gather to all process .. this only gathers to the root
    mpi.world.barrier()

    if(mpi.rank == 0):
        tot_max = 0.0
        for i in range(0, len(max_values)):
            if(max_values[i] > tot_max):
                tot_max = max_values[i]

        tot_max = math.sqrt(tot_max)
        print(tot_max)

        if (benchmarking.InBenchmarkingMode()):
            benchmarking.Output(time, "Time")
            benchmarking.Output(tot_max, "maximum displacement in the model", 0.00001)

    mpi.world.barrier()
Example #6
0
def BenchmarkCheck(model_part):
    for node in model_part.Nodes:
        x = node.X
        y = node.Y
        if(x == 0.0):
            temperature = node.GetSolutionStepValue(TEMPERATURE)
            benchmarking.Output(node.Id, "ID node", 1, 1)
            benchmarking.Output(temperature, "Temperature", 0.001, 0.001)
Example #7
0
def BenchmarkCheck(time, model_part):
    dist = 0.0
    for node in model_part.Nodes:
        if (node.Id == 15):
            dist = node.GetSolutionStepValue(DISTANCE)

    benchmarking.Output(time, "Time", 1e-7)
    benchmarking.Output(dist, "distance on node #15", 0.00001)
Example #8
0
def BenchmarkCheck(time, node1):
    benchmarking.Output(time, "Time")
    print(
        "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII"
    )
    benchmarking.Output(node1.GetSolutionStepValue(PRESSURE),
                        "Node 1 pressure", 1.0, .1)
    benchmarking.Output(node1.GetSolutionStepValue(VELOCITY_Y),
                        "Node 2 velocity_y", 1.0, .1)
def AnalyticalResults(time, node1, node2, node3, node4):
    benchmarking.Output(node1.GetSolutionStepValue(DISPLACEMENT_Z),
                        "Node 1 Displacement_z", 0.00001)
    benchmarking.Output(node2.GetSolutionStepValue(DISPLACEMENT_Z),
                        "Node 2 Displacement_z", 0.00001)
    benchmarking.Output(node3.GetSolutionStepValue(DISPLACEMENT_Z),
                        "Node 3 Displacement_z", 0.00001)
    benchmarking.Output(node4.GetSolutionStepValue(DISPLACEMENT_Z),
                        "Node 4 Displacement_z", 0.00001)
Example #10
0
def BenchmarkCheck(time, model_part):
    print("GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGg")
    for node in model_part.Nodes:
        flag = node.GetValue(FLAG_VARIABLE)
        if(flag == 12.0):
            reaction = node.GetSolutionStepValue(DISPLACEMENT)
            reaction_norm = pow(reaction[0] ** 2 + reaction[1] ** 2, 0.5)

            benchmarking.Output(time, "Time")
            benchmarking.Output(reaction_norm, "Raaction_Norm", 100.0)
Example #11
0
def WriteBenchmarkResults(model_part):

    [dx_min, dy_min, dz_min] = FindMinDispY(model_part.Nodes)
    print([dx_min, dy_min, dz_min])

    if (benchmarking.InBenchmarkingMode()):
        abs_tol = 1e-9
        rel_tol = 1e-5
        benchmarking.Output(dx_min, "min dx", abs_tol, rel_tol)
        benchmarking.Output(dy_min, "min dy", abs_tol, rel_tol)
        benchmarking.Output(dz_min, "min dz", abs_tol, rel_tol)
Example #12
0
def BenchmarkCheck(time, model_part):
    min_press = 0.0
    max_press = 0.0

    for node in model_part.Nodes:
        press = node.GetSolutionStepValue(PRESSURE)
        if (press < min_press):
            min_press = press
        if (press > max_press):
            max_press = press

    benchmarking.Output(min_press, "min_pressure ", 0.0001, 0.0001)
    benchmarking.Output(max_press, "max_pressure ", 0.0001, 0.0001)
Example #13
0
def BenchmarkCheck(time, model_part):
    bottom_right_node = model_part.Nodes[320]
    top_left_node = model_part.Nodes[646]

    num = bottom_right_node.GetSolutionStepValue(
        PRESSURE) - bottom_right_node.GetSolutionStepValue(PRESSURE, 1)
    denom = abs(bottom_right_node.GetSolutionStepValue(PRESSURE)) + 0.0001
    benchmarking.Output(time, "Time")

    benchmarking.Output(num / denom, "pressure on node 320 ", 0.01)
    benchmarking.Output(bottom_right_node.GetSolutionStepValue(DISTANCE),
                        "distance on node 320 ", 0.01)
    benchmarking.Output(top_left_node.GetSolutionStepValue(DISTANCE),
                        "distance on node 646 ", 0.01)
Example #14
0
def BenchmarkCheck(time, model_part):
    max_temp = 0.0
    id_max_temp = 0

    for node in model_part.Nodes:
        temp = node.GetSolutionStepValue(TEMPERATURE)
        if (temp > max_temp):
            max_temp = temp
            id_max_temp = node.Id

    benchmarking.Output(time, "Time", 1e-7)
    benchmarking.Output(max_temp, "minimum temperature", 0.00001)
    benchmarking.Output(id_max_temp, "Id of the node with maximum temperature",
                        0.0)
Example #15
0
def BenchmarkCheck(time, model_part):
    dist1 = 0.0
    dist2 = 0.0
    dist3 = 0.0
    for node in model_part.Nodes:
        if (node.Id == 1243):
            dist1 = node.GetSolutionStepValue(DISTANCE)
        if (node.Id == 924):
            dist2 = node.GetSolutionStepValue(DISTANCE)
        if (node.Id == 446):
            dist3 = node.GetSolutionStepValue(DISTANCE)
    benchmarking.Output(time, "Time")
    benchmarking.Output(dist1, "distance on node #1243", 0.00001)
    benchmarking.Output(dist2, "distance on node #924", 0.00001)
    benchmarking.Output(dist3, "distance on node #446", 0.00001)
def BenchmarkCheckPfem(time, model_part):
    dist1 = 0.0
    dist2 = 0.0
    dist3 = 0.0
    for node in model_part.Nodes:
        if (node.Id == 122):
            dist1 = node.GetSolutionStepValue(TEMPERATURE)
        if (node.Id == 199):
            dist2 = node.GetSolutionStepValue(TEMPERATURE)
        if (node.Id == 61):
            dist3 = node.GetSolutionStepValue(TEMPERATURE)
    benchmarking.Output(time, "Time")
    benchmarking.Output(dist1, "temperature on node #122", 0.00001)
    benchmarking.Output(dist2, "temperature on node #199", 0.00001)
    benchmarking.Output(dist3, "temperature on node #61", 0.00001)
def BenchmarkCheck(time, model_part):
    dist1 = 0.0
    dist2 = 0.0
    dist3 = 0.0
    for node in model_part.Nodes:
        if (node.Id == 11241):
            dist1 = node.GetSolutionStepValue(DISTANCE)
        if (node.Id == 7742):
            dist2 = node.GetSolutionStepValue(DISTANCE)
        if (node.Id == 4535):
            dist3 = node.GetSolutionStepValue(DISTANCE)
    benchmarking.Output(time, "Time")
    benchmarking.Output(dist1, "distance on node #11241", 0.00001)
    benchmarking.Output(dist2, "distance on node #7742", 0.00001)
    benchmarking.Output(dist3, "distance on node #4535", 0.00001)
Example #18
0
def BenchmarkCheck(time, model_part):
    max_press = 0.0
    min_press = 0.0
    vel2min = 10000.0
    id_min_vel = 0
    x_min_vel = 0.0
    y_min_vel = 0.0
    for node in model_part.Nodes:
        press = node.GetSolutionStepValue(PRESSURE)
        if (press > max_press):
            max_press = press
        elif (press < min_press):
            min_press = press

        x = node.X
        y = node.Y
        vel = node.GetSolutionStepValue(VELOCITY)
        vel2 = vel[0]**2 + vel[1]**2
        if (x > 0.1 and x < 0.9 and y > 0.1 and y < 0.9):
            if (vel2 < vel2min):
                vel2min = vel2
                id_min_vel = node.Id
                x_min_vel = node.X
                y_min_vel = node.Y

    benchmarking.Output(time, "Time", 1e-7)
    benchmarking.Output(min_press, "minimum pressure", 0.00001)
    benchmarking.Output(max_press, "maximum pressure", 0.00001)
    benchmarking.Output(id_min_vel,
                        "Id of the node with minimum velocity norm", 0.0)
    benchmarking.Output(x_min_vel, "coord x minimum velocity norm", 0.0)
    benchmarking.Output(y_min_vel, "coord y minimum velocity norm", 0.0)
def WriteBenchmarkResults(model_part):

    if (benchmarking.InBenchmarkingMode()):
        # find max Y rotation
        r_max = 0.0
        for node in model_part.Nodes:
            ir = node.GetSolutionStepValue(ROTATION_Z)
            if (ir > r_max):
                r_max = ir
        # write
        abs_tol = 1e-9
        rel_tol = 1e-5
        benchmarking.Output(r_max, "Z Rotation", abs_tol, rel_tol)
def WriteBenchmarkResults(model_part):

    # write
    abs_tol = 1e-9
    rel_tol = 1e-5

    [dx_min, dy_min, dz_min] = FindMinDisp(model_part.Nodes)
    print([dx_min, dy_min, dz_min])

    if (benchmarking.InBenchmarkingMode()):
        # write
        abs_tol = 1e-9
        rel_tol = 1e-5
        benchmarking.Output(dx_min, "min dx", abs_tol, rel_tol)
        benchmarking.Output(dy_min, "min dy", abs_tol, rel_tol)
        benchmarking.Output(dz_min, "min dz", abs_tol, rel_tol)

    [dx_max, dy_max, dz_max] = FindMaxDisp(model_part.Nodes)
    print([dx_max, dy_max, dz_max])

    if (benchmarking.InBenchmarkingMode()):
        benchmarking.Output(dx_max, "max dx", abs_tol, rel_tol)
        benchmarking.Output(dy_max, "max dy", abs_tol, rel_tol)
        benchmarking.Output(dz_max, "max dz", abs_tol, rel_tol)
Example #21
0
def BenchmarkCheck(time, node1, node2):
    benchmarking.Output(time, "Time")
    benchmarking.Output(node1.GetSolutionStepValue(PRESSURE), "Node 1 pressure", 1.0)
    benchmarking.Output(node2.GetSolutionStepValue(PRESSURE), "Node 2 pressure", 1.0)
Example #22
0
def BenchmarkCheck(o_model_part, d_model_part):
    # Find some nodes in both meshes and compare their vaules
    for node in o_model_part.Nodes:
        if (node.X == -5) and (node.Y == -5) and (node.Z == -5):
            press_1o = node.GetSolutionStepValue(PRESSURE, 0)
            velX_1o = node.GetSolutionStepValue(VELOCITY_X, 0)
            velY_1o = node.GetSolutionStepValue(VELOCITY_Y, 0)
            velZ_1o = node.GetSolutionStepValue(VELOCITY_Z, 0)
        elif (node.X == -5) and (node.Y == 5) and (node.Z == -5):
            press_2o = node.GetSolutionStepValue(PRESSURE, 0)
            velX_2o = node.GetSolutionStepValue(VELOCITY_X, 0)
            velY_2o = node.GetSolutionStepValue(VELOCITY_Y, 0)
            velZ_2o = node.GetSolutionStepValue(VELOCITY_Z, 0)
        elif (node.X == 5) and (node.Y == 5) and (node.Z == 5):
            press_3o = node.GetSolutionStepValue(PRESSURE, 0)
            velX_3o = node.GetSolutionStepValue(VELOCITY_X, 0)
            velY_3o = node.GetSolutionStepValue(VELOCITY_Y, 0)
            velZ_3o = node.GetSolutionStepValue(VELOCITY_Z, 0)
        elif (node.X == 5) and (node.Y == -5) and (node.Z == 5):
            press_4o = node.GetSolutionStepValue(PRESSURE, 0)
            velX_4o = node.GetSolutionStepValue(VELOCITY_X, 0)
            velY_4o = node.GetSolutionStepValue(VELOCITY_Y, 0)
            velZ_4o = node.GetSolutionStepValue(VELOCITY_Z, 0)

    for node in d_model_part.Nodes:
        if (node.X == -5) and (node.Y == -5) and (node.Z == -5):
            press_1d = node.GetSolutionStepValue(PRESSURE, 0)
            velX_1d = node.GetSolutionStepValue(VELOCITY_X, 0)
            velY_1d = node.GetSolutionStepValue(VELOCITY_Y, 0)
            velZ_1d = node.GetSolutionStepValue(VELOCITY_Z, 0)
        elif (node.X == -5) and (node.Y == 5) and (node.Z == -5):
            press_2d = node.GetSolutionStepValue(PRESSURE, 0)
            velX_2d = node.GetSolutionStepValue(VELOCITY_X, 0)
            velY_2d = node.GetSolutionStepValue(VELOCITY_Y, 0)
            velZ_2d = node.GetSolutionStepValue(VELOCITY_Z, 0)
        elif (node.X == 5) and (node.Y == 5) and (node.Z == 5):
            press_3d = node.GetSolutionStepValue(PRESSURE, 0)
            velX_3d = node.GetSolutionStepValue(VELOCITY_X, 0)
            velY_3d = node.GetSolutionStepValue(VELOCITY_Y, 0)
            velZ_3d = node.GetSolutionStepValue(VELOCITY_Z, 0)
        elif (node.X == 5) and (node.Y == -5) and (node.Z == 5):
            press_4d = node.GetSolutionStepValue(PRESSURE, 0)
            velX_4d = node.GetSolutionStepValue(VELOCITY_X, 0)
            velY_4d = node.GetSolutionStepValue(VELOCITY_Y, 0)
            velZ_4d = node.GetSolutionStepValue(VELOCITY_Z, 0)

    press_1 = press_1d - press_1o
    press_2 = press_2d - press_2o
    press_3 = press_3d - press_3o
    press_4 = press_4d - press_4o

    velX_1 = velX_1o - velX_1d
    velX_2 = velX_2o - velX_2d
    velX_3 = velX_3o - velX_3d
    velX_4 = velX_4o - velX_4d

    velY_1 = velY_1o - velY_1d
    velY_2 = velY_2o - velY_2d
    velY_3 = velY_3o - velY_3d
    velY_4 = velY_4o - velY_4d

    velZ_1 = velZ_1o - velZ_1d
    velZ_2 = velZ_2o - velZ_2d
    velZ_3 = velZ_3o - velZ_3d
    velZ_4 = velZ_4o - velZ_4d

    benchmarking.Output(press_1, "Difference in pressure in test point 1")
    benchmarking.Output(velX_1, "Difference in x velocity in test point 1")
    benchmarking.Output(velY_1, "Difference in y velocity in test point 1")
    benchmarking.Output(velZ_1, "Difference in z velocity in test point 1")

    benchmarking.Output(press_2, "Difference in pressure in test point 2")
    benchmarking.Output(velX_2, "Difference in x velocity in test point 2")
    benchmarking.Output(velY_2, "Difference in y velocity in test point 2")
    benchmarking.Output(velZ_2, "Difference in z velocity in test point 2")

    benchmarking.Output(press_3, "Difference in pressure in test point 3")
    benchmarking.Output(velX_3, "Difference in x velocity in test point 3")
    benchmarking.Output(velY_3, "Difference in y velocity in test point 3")
    benchmarking.Output(velZ_3, "Difference in z velocity in test point 3")

    benchmarking.Output(press_4, "Difference in pressure in test point 4")
    benchmarking.Output(velX_4, "Difference in x velocity in test point 4")
    benchmarking.Output(velY_4, "Difference in y velocity in test point 4")
    benchmarking.Output(velZ_4, "Difference in z velocity in test point 4")
Example #23
0
def BenchmarkCheck(time, node1):
    benchmarking.Output(time, "Time")
    benchmarking.Output(node1.GetSolutionStepValue(PRESSURE),
                        "Node 1 pressure", 0.05)
    benchmarking.Output(node1.GetSolutionStepValue(DISTANCE),
                        "Node 1 distance", 0.05)
Example #24
0
def BenchmarkCheck(time, model_part, section_nodes, center):

    DragLift = CalculateDragLift(time, section_nodes, center)

    benchmarking.Output(time, "Time", 0.0001)
    benchmarking.Output(DragLift[0], "drag", 0.5, 0.01)
Example #25
0
# generate a new property in the origin_model_part to insert control values
prop_initial_value = 123.0
prop_test_value = prop_initial_value
origin_model_part.Properties[10].SetValue(PRESSURE, prop_initial_value)

# generate a new model part with different elements. Will use THE SAME Nodes, Properties and ProcessInfo as the original one
# but will have different Elements and Conditions
connectivity_model_part_generator = ConnectivityPreserveModeler()
connectivity_model_part_generator.GenerateModelPart(origin_model_part,
                                                    new_model_part,
                                                    "ConvDiff2D",
                                                    "ThermalFace2D")

# verify buffer size is assigned correctly
benchmarking.Output(
    origin_model_part.GetBufferSize(),
    "test expected value for buffer_size on origin_model_part", buffer_size)
benchmarking.Output(new_model_part.GetBufferSize(),
                    "test expected value for buffer_size on new_model_part",
                    buffer_size)

# loop over time and verify that the ProcessInfo behaves correctly
dt = 0.1
time = 0.0
for i in range(0, 30):
    time = time + dt

    # we advance in time ONE of the model_parts
    # note that it would be an error to advance both of them since the processinfo is shared
    origin_model_part.CloneTimeStep(time)
Example #26
0
def AnalyticalResults(time, model_part):
    benchmarking.Output(time, "Time")
    benchmarking.Output(0.000, "Cumulative diff betw DISPL_X and exact solution", 0.0000001)
Example #27
0
def BenchmarkCheck(time, model_part):
    benchmarking.Output(time, "Time")
    err = 0.0
    for node in model_part.Nodes:
        err = err + (node.X - node.GetSolutionStepValue(DISPLACEMENT_X)) ** 2;
    benchmarking.Output(err, "Cumulative diff betw DISPL_X and exact solution", 0.0000001)
Example #28
0
    print("Stage 2, STEP = ", step)

    fluid_solver.Solve()
    PrintDrag(drag_list, drag_file_output_list, fluid_model_part, time)

for node in fluid_model_part.Nodes:
    vel   = node.GetSolutionStepValue(VELOCITY)
    press = node.GetSolutionStepValue(PRESSURE)
    node.SetSolutionStepValue(PRIMAL_VELOCITY,vel)
    node.SetSolutionStepValue(PRIMAL_PRESSURE,press)

# Adjoint solution
adjoint_solver.Solve()
print("adjoint problem solved")

adjoint_solver.ComputeSensitivity()
print("sensitivity computed")

gid_io.write_results(
    time,
    fluid_model_part,
    ProjectParameters.nodal_results,
    ProjectParameters.gauss_points_results)
gid_io.finalize_results()

for i in drag_file_output_list:
    i.close()

benchmarking.Output(TestNode1.GetSolutionStepValue(SHAPE_SENSITIVITY_X), "Test node 1 SHAPE_SENSITIVITY_X", None, 0.001)
benchmarking.Output(TestNode2.GetSolutionStepValue(SHAPE_SENSITIVITY_Y), "Test node 2 SHAPE_SENSITIVITY_Y", None, 0.001)
def BenchmarkCheck(time, node1):
    benchmarking.Output(time, "Time")
    benchmarking.Output(node1.GetSolutionStepValue(DISPLACEMENT_X),
                        "Node 1 Desplacement_x", 1.0)
    benchmarking.Output(node1.GetSolutionStepValue(DISPLACEMENT_Y),
                        "Node 1 Desplacement_y", 1.0)
Example #30
0
def BenchmarkTest(time, node1, node2):
    benchmarking.Output(time, "Time", 1e-7)
    benchmarking.Output(node1.GetSolutionStepValue(TEMPERATURE),
                        "TEST NODE 1 TEMPERATURE=", None, 0.005)
    benchmarking.Output(node2.GetSolutionStepValue(TEMPERATURE),
                        "TEST NODE 2 TEMPERATURE=", None, 0.005)