CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > Siemens > STAR-CCM+

Java

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By me3840

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 10, 2017, 09:11
Default Java
  #1
New Member
 
Vincent
Join Date: Jul 2017
Posts: 9
Rep Power: 8
Vincent_GDC is on a distinguished road
Hi,

I am trying to write out report values. But I get these result in STAR-CCM+ when playing the macro:

Part Value (Pa)
------------------------------ -------------
Plane_Water_1 1.479126e+04
-------------
Total: 1.479126e+04

Surface Average of Total Pressure on Volume Mesh
This part is longer but I only show this lines, to messy otherwise


The macro I wrote is as follows:

************************************************** ************************************************** ***********
************************************************** ************************************************** ***********

public void PrintReports(Simulation SIM){

for(AreaAverageReport FP: SIM.getReportManager().getObjectsOf(AreaAverageRep ort.class)){

ArrayList<String> list = new ArrayList<String>();
list.add("Pressure_Plane_Water_1-Surface_Average");
list.add("Pressure_Plane_Water_2-Surface_Average");
list.add("Pressure_Plane_Water_3-Surface_Average");
list.add("Pressure_Plane_Water_4-Surface_Average");

if (list.contains(FP.getPresentationName())){

FP.printReport();
}
}
}

************************************************** ************************************************** ***********
************************************************** ************************************************** ***********

How can I print reports that only gives the name and value as for instance:
Plane_Water_1 1.568415e+04


Also how can I print reports that begin with the same letters?

Last edited by Vincent_GDC; July 10, 2017 at 12:13.
Vincent_GDC is offline   Reply With Quote

Old   July 10, 2017, 22:13
Default
  #2
Senior Member
 
Join Date: Nov 2010
Location: USA
Posts: 1,232
Rep Power: 24
me3840 is on a distinguished road
You need to do:
SIM.println(FP.getPresentationName() + " " + FP.getReportMonitorValue());
Vincent_GDC likes this.
me3840 is offline   Reply With Quote

Old   July 11, 2017, 06:04
Default
  #3
New Member
 
Vincent
Join Date: Jul 2017
Posts: 9
Rep Power: 8
Vincent_GDC is on a distinguished road
me3840, thank you for your reply. It looks much better now. You are really great
Vincent_GDC is offline   Reply With Quote

Old   July 11, 2017, 07:43
Default
  #4
New Member
 
Vincent
Join Date: Jul 2017
Posts: 9
Rep Power: 8
Vincent_GDC is on a distinguished road
May I ask you another question. All of this is for training purposes. I have created a basic model in Starccm+ with two boundaries. What I want to do is to increase the mass flow rate when the average velocity report on the pressure boundary is < 0. And decrease the massflow if the average velocity report is > 0. I want to basically balance the flow out from the pressure boundary. I have commented the places I have difficulties with.

private void execute0() {

Simulation SIM =
getActiveSimulation();

Region RG =
SIM.getRegionManager().getRegion("Region 2");

AreaAverageReport AAR =
((AreaAverageReport) SIM.getReportManager().getReport("EQD_Average_Velo city"));

Boundary EQD_p0 =
RG.getBoundaryManager().getBoundary("Surface Extruder_EQD_p0.Original_part.pressure_out_EQD_p0" );



for(MassFlowRateProfile MF: EQD_p0.getValues().getObjectsOf(MassFlowRateProfil e.class)){

if(AAR.getReportMonitorValue() > 0){

// Here I want to decrease the massflow little by little until the velocity report is
// 0.
}

if(AAR.getReportMonitorValue() > 0){

// Here I want to increase the massflow little by little until the velocity report is
// 0.
}

}

}
Vincent_GDC is offline   Reply With Quote

Old   July 11, 2017, 09:06
Default
  #5
New Member
 
Vincent
Join Date: Jul 2017
Posts: 9
Rep Power: 8
Vincent_GDC is on a distinguished road
I updated the code and the macro is running. However, it does not change the Mass flow rate value in starccm+ in region boundary. I want it to update that value every 50 iterations or so.

Simulation SIM =
getActiveSimulation();

Region RG =
SIM.getRegionManager().getRegion("Region 2");

AreaAverageReport AAR =
((AreaAverageReport) SIM.getReportManager().getReport("EQD_Average_Velo city"));

Boundary EQD_p0 =
RG.getBoundaryManager().getBoundary("Surface Extruder_EQD_p0.Original_part.pressure_out_EQD_p0" );

MassFlowRateProfile MF =
EQD_p0.getValues().get(MassFlowRateProfile.class);


for(;{

SIM.getSimulationIterator().step(50);

if(AAR.getReportMonitorValue() > 0){

MF.getMethod(ConstantScalarProfileMethod.class).ge tQuantity().setValue(1.0-(1/10));
SIM.println("Lowering the Mass Flow to" + "kg/s");

}

if(AAR.getReportMonitorValue() < 0){

MF.getMethod(ConstantScalarProfileMethod.class).ge tQuantity().setValue(1.0+(1/10));
SIM.println("Raising the Mass Flow to" + "kg/s");

}

}

}
Vincent_GDC is offline   Reply With Quote

Old   July 13, 2017, 07:34
Default
  #6
New Member
 
Vincent
Join Date: Jul 2017
Posts: 9
Rep Power: 8
Vincent_GDC is on a distinguished road
I managed to solve this issue. Thank you for your help.
Vincent_GDC is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java sarahtuvia STAR-CCM+ 0 March 31, 2016 10:42
Running salome-meca from a java script Iche_Bins Structural Mechanics 0 October 9, 2013 06:44
Macro to access java files in sub-directory abraum STAR-CCM+ 3 July 11, 2012 02:46
Getting OpenFOAM to coexist with an existing JAVA VM nik777 OpenFOAM Installation 5 February 22, 2007 07:21
java vs c++ zxaar Main CFD Forum 10 December 3, 2004 02:05


All times are GMT -4. The time now is 12:45.