3.1.8.1. c3po.services.ListingWriter module
Contain the class ListingWriter.
- class c3po.services.ListingWriter.ListingWriter(listingFile)
Bases:
objectListingWriterallows, in association withc3po.services.tracer.tracer, to write a global coupling listing file with calculation time measurement.ListingWriteris completed by the funtionsmergeListing(),getTotalTimePhysicsDriver()andgetTimesExchanger().- __init__(listingFile)
Build a
ListingWriterobject.- Parameters:
listingFile – A file object which has to be already open in written-binary mode (
file = open("file.txt", "wb")). It has to be closed (file.close()) by caller.
- enumBilan = 3
- enumCloseTop = 2
- enumContinue = 6
- enumEntete = 1
- enumInterrupt = 5
- enumTerm = 4
- enumTop = 0
- initialize(physics, exchangers, force=False)
Clear and initialize the object.
Can be replace by a call to
terminate()(optional for the first call) followed by calls tosetPhysicsDriverName()andsetExchangerName().setPhysicsDriverName()andsetExchangerName()can also be used afterinitialize(), but not before (what is set before is forgotten).- Parameters:
physics (list[tuple]]) – A list of tuples
(object, name).objectshould be aPhysicsDriver, modified withc3po.services.tracer.tracer()to point on thisListingWriterobject. An object that does not meet these conditions is ignored. A column (entitled withname) is created in the listing file for each of them.exchangers (list[tuple]]) – A list of tuples
(object, name).objectshould be anExchangerobject, modified withc3po.services.tracer.tracer()to point on thisListingWriterobject. An object that does not meet these conditions is ignored.nameallows to identify them in the final listing file.force (bool) – If set to True,
physicsandexchangersare added even if they do not meet the previously defined conditions.
- prepare()
INTERNAL
- setExchangerName(exchanger, name, force=False)
Get ready to write a listing with the provided
Exchanger.- Parameters:
exchanger (Exchanger) – A
Exchangerobject, modified withc3po.services.tracer.tracer()to point on thisListingWriterobject. Ifexchangerdoes not meet these conditions, it is ignored. Otherwise, a lign will be written in the listing for each call of exchanger’sexchange()method .name (str) – The name to use for
exchangerin the listing.force (bool) – If set to True,
exchangeris added even if it does not meet the previously defined conditions.
- setPhysicsDriverName(physics, name, force=False)
Get ready to write a listing with the provided
PhysicsDriver.- Parameters:
physics (PhysicsDriver) – A
PhysicsDriverobject, modified withc3po.services.tracer.tracer()to point on thisListingWriterobject. Ifphysicsdoes not meet these conditions, it is ignored. Otherwise, a column (entitled withname) will be created in the listing file for it.name (str) – The name to use for
physicsin the listing.force (bool) – If set to True,
physicsis added even if it does not meet the previously defined conditions.
- terminate()
Get ready to write a new listing.
What was previously set by
initialize(),setPhysicsDriverName()andsetExchangerName()is forgotten.
- writeAfter(sourceObject, inputVar, outputTuple, methodName, presentTime, calculationTime)
INTERNAL
- writeInitialize(presentTime)
INTERNAL
- writeTerminate()
INTERNAL
- writeValidate(timeValid)
INTERNAL
- class c3po.services.ListingWriter.MergedListingWriter(listingFile)
Bases:
ListingWriterINTERNAL
- __init__(listingFile)
INTERNAL
- enumExchangeElem = 9
- enumExchangeEnd = 8
- enumExchangeStart = 7
- enumPhysicsEnd = 8
- enumPhysicsStart = 7
- prepare()
INTERNAL
- readLastLine()
INTERNAL
- writeAfterExchange(sourceObject, toWrite, methodName, involvedPhysics, runningPhysics, presentTime)
INTERNAL
- writeAfterNew(sourceObject, toWrite, methodName, runningPhysics, presentTime)
INTERNAL
- writeBefore(sourceObject, toWrite, methodName, runningPhysics, presentTime, calculationTime)
INTERNAL
- writeBeforeExchange(sourceObject, toWrite, methodName, involvedPhysics, runningPhysics, presentTime, calculationTime)
INTERNAL
- c3po.services.ListingWriter.getFormattedTime(timeValue)
INTERNAL
- c3po.services.ListingWriter.getTimesExchanger(listingName, exchangerName, physicsDriverNames)
getTimesExchanger()reads a listing file produced byListingWriteror mergeListing and returns time information about a chosen exchanger (during the last calculation).For each
PhysicsDriverinvolved in the exchange, the function distinguishes between exchange time and waiting time. The exchange is assumed to really begin when all involvedPhysicsDriverenter the exchange. For each of them, the waiting time is the time spent in the exchange before they all enter it. The exchange time is the time from this “real beginning” to the end of the exchange (from the point of view of eachPhysicsDriver).- Parameters:
listingName – Name of the listing file to read.
exchangerName – Name (given in the listing file) of the
Exchangerfor which time information is requested.physicsDriverNames (list) – List of the names of the
PhysicsDriver(given in the listing file) involved in theExchanger. They must be really involved!
- Returns:
A list of
len(physicsDriverNames)elements, in the same order thanphysicsDriverNames. Each element is a list of two values: first the total exchange time spent by thisPhysicsDriverin theExchanger, then its total waiting time in theExchanger.- Return type:
- c3po.services.ListingWriter.getTotalTimePhysicsDriver(listingName, physicsDriverName, methodNames=['initialize', 'computeTimeStep', 'initTimeStep', 'solveTimeStep', 'iterateTimeStep', 'validateTimeStep', 'setStationaryMode', 'abortTimeStep', 'resetTime', 'terminate', 'save', 'restore'])
getTotalTimePhysicsDriver()reads a listing file produced byListingWriteror mergeListing and returns the total time spent by onePhysicsDriverin indicated methods (in the last calculation).- Parameters:
listingName – Name of the listing file to read.
physicsDriverName – Name (given in the listing file) of the
PhysicsDriverfor which the total time is requested.methodNames (list) – List of the names of the methods to take into account. By defaut: everything but
"exchange": ["initialize", "computeTimeStep", "initTimeStep", "solveTimeStep", "iterateTimeStep", "validateTimeStep", "setStationaryMode", "abortTimeStep", "resetTime", "terminate", "save", "restore"].
- Return type:
The total time spent by the
PhysicsDriverin the indicated methods.
- c3po.services.ListingWriter.goToLastBox(listingFile)
INTERNAL
- c3po.services.ListingWriter.mergeListing(listingsName, newListingName)
mergeListing()allows to merge listing files produced by ListingWriter (or by previous call tomergeListing()).It is designed to produce a comprehensive view of a MPI calculation. Only the last listing box of the provided files are considered.
Warning
Each of the provided files must contain one and only one listing (one table).
- Parameters:
listingsName (list) – List of the name of the listing files to merge.
newListingName – Name of the file to write.