proteus.Gauges module

Auxiliary variable classes for storing solutions at points and along lines to mimic gauges in lab and field experiments.

Inheritance diagram of proteus.Gauges

proteus.Gauges.PointGauges(gauges, activeTime=None, sampleRate=0, fileName='point_gauges.csv')[source]

Create a set of point gauges that will automatically be serialized as CSV data to the requested file.

Parameters:gauges – An iterable of “gauges”. Each gauge is specified by a 2-tuple, with the first element in the tuple a set of fields to be monitored, and the second element a tuple of the 3-space representations of the gauge locations.

See the Gauges class for an explanation of the other parameters.

Example:

p = PointGauges(gauges=((('u', 'v'), ((0.5, 0.5, 0), (1, 0.5, 0))),
                       (('p',), ((0.5, 0.5, 0),))),
                activeTime=(0, 2.5),
                sampleRate=0.2,
                fileName='combined_gauge_0_0.5_sample_all.csv')

This creates a PointGauges object that will monitor the u and v fields at the locations [0.5, 0.5, 0] and [1, 0.5, 0], and the p field at [0.5, 0.5, 0] at simulation time between = 0 and 2.5 with samples taken no more frequently than every 0.2 seconds. Results will be saved to: combined_gauge_0_0.5_sample_all.csv.

proteus.Gauges.LineGauges(gauges, activeTime=None, sampleRate=0, fileName='line_gauges.csv')[source]

Create a set of line gauges that will automatically be serialized as CSV data to the requested file. The line gauges will gather data at every element on the mesh between the two endpoints on each line.

Parameters:gauges – An iterable of “gauges”. Each gauge is specified by a 2-tuple, with the first element in the tuple a set of fields to be monitored, and the second element a list of pairs of endpoints of the gauges in 3-space representation.

See the Gauges class for an explanation of the other parameters.

proteus.Gauges.LineIntegralGauges(gauges, activeTime=None, sampleRate=0, fileName='line_integral_gauges.csv')[source]

Create a set of line integral gauges that will automatically be serialized as CSV data to the requested file.

Parameters:gauges – An iterable of “gauges”. Each gauge is specified by a 2-tuple, with the first element in the tuple a set of fields to be monitored, and the second element a list of pairs of endpoints of the gauges in 3-space representation.

See the Gauges class for an explanation of the other parameters.

class proteus.Gauges.Gauges(fields, activeTime=None, sampleRate=0, fileName='gauges.csv', points=None, lines=None, integrate=False)[source]

Bases: proteus.AuxiliaryVariables.AV_base

Monitor fields at specific values.

This class provides a generic point-wise and line-integral monitor that can be instantiated and attached to Proteus simulations by including them in the list of Auxiliary Variables in problem setup.

Each Gauges instance may contain one or more fields, which may contain one or more locations to monitor. The monitoring is defined over a given time and sample rate, and a filename is also supplied. All results are serialized to a CSV file.

Parallel Implementation Notes: After the gauge has been attached, all processes are partitioned into Gauge Owners and non-Gauge Owners. The calculate method is a “no-op” for non-Owners. For Gauge Owners, all values are computed individually, then collectively transmitted to the “root” process, which is the only process responsible for serializing gauge results to disk. This code has not been aggressively vetted for parallel correctness or scalability.

Create a set of gauges that will automatically be serialized as CSV data to the requested file.

Parameters:
  • activeTime – If not None, a 2-tuple of start time and end time for which the point gauge is active.
  • sampleRate – The intervals at which samples should be measured. Note that this is a rough lower bound, and that the gauge values could be computed less frequently depending on the time integrator. The default value of zero computes the gauge values at every time step.
  • fileName – The name of the file to serialize results to.

Data is currently column-formatted, with 10 characters allotted to the time field, and 45 characters allotted to each point field.

getLocalNearestNode(location)[source]
getLocalElement(femSpace, location, node)[source]

Given a location and its nearest node, determine if it is on a local element.

Returns None if location is not on any elements owned by this process

findNearestNode(femSpace, location)[source]

Given a gauge location, attempts to locate the most suitable process for monitoring information about this location, as well as the node on the process closest to the location.

Returns a 2-tuple containing an identifier for the closest ‘owning’ process as well as the local ids of the node and nearest element.

buildQuantityRow(m, femFun, quantity_id, quantity)[source]

Builds up contributions to gauge operator from the underlying element space

initOutputWriter()[source]

Initialize communication strategy for collective output of gauge data.

On the root process in this communicator, create a map of quantity owners and the corresponding location in their arrays. This process is responsible for collecting gauge data and saving it to disk.

Gauge data is globally ordered by field, then by location id (as ordered by globalMeasuredQuantities)

buildGaugeComm()[source]

Create a communicator composed only of processes that own gauge quantities.

Collective over global communicator. Builds a local communicator for collecting all gauge data. This communicator contains only processes that will contain gauge data.

addLineGaugePoints(line, line_segments)[source]

Add all gauge points from each line into self.points

identifyMeasuredQuantities()[source]

build measured quantities, a list of fields

Each field in turn contains a list of gauge locations and their accompanying nearest node only local quantities are saved

buildPointGaugeOperators()[source]

Build the linear algebra operators needed to compute the point gauges.

The operators are all local since the point gauge measurements are calculated locally.

pruneDuplicateSegments(endpoints, length_segments)[source]

prune duplicate segments across processors

endpoints - a pair of points in 3-space defining the line length_segments - a pair of intersections augmented by length

this could be optimized

getMeshIntersections(line)[source]
buildLineIntegralGaugeOperators(lines, linesSegments)[source]

Build the linear algebra operators needed to compute the line integral gauges.

The operators are local to each process, contributions are currently summed in the output functions.

attachModel(model, ar)[source]

Attach this gauge to the given simulation model.

get_time()[source]

Returns the current model time

outputHeader()[source]

Outputs a single header for a CSV style file to self.file

outputRow(time)[source]

Outputs a single row of currently calculated gauge data to self.file

calculate()[source]

Computes current gauge values, updates open output files