All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.mines.jtk.interp.TimeMarker3X Maven / Gradle / Ivy

The newest version!
/****************************************************************************
Copyright 2009, Colorado School of Mines and others.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
****************************************************************************/
package edu.mines.jtk.interp;

import java.util.ArrayList;
import java.util.Random;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;

import edu.mines.jtk.dsp.Tensors3;
import edu.mines.jtk.util.Stopwatch;
import static edu.mines.jtk.util.ArrayMath.*;

/**
 * EXPERIMENTAL: uses a heap instead of random shuffling of known samples.
 * 

* A time and closest-point transform for 3D anisotropic eikonal equations. * Transforms an array of times and marks for known samples into an array * of times and marks for all samples. Known samples are those for which * times are zero, and times and marks for known samples are not modified. *

* Times for unknown samples are computed by solving an anisotropic eikonal * equation grad(t) dot W grad(t) = 1, where W denotes a positive-definite * (velocity-squared) metric tensor field. The solution times t represent * the traveltimes from one known sample to all unknown samples. Separate * solution times t are computed for each known sample that has at least * one unknown neighbor. (Such a known sample is sometimes called a * "source point.") The output time for each sample is the minimum time * computed in this way for all such known samples. Therefore, the times * output for unknown samples are the traveltimes to the closest known * samples, where "closest" here means least time, not least distance. *

* As eikonal solutions t are computed for each known sample, the mark * for that known sample is used to mark all unknown samples for which * the solution time is smaller than the minimum time computed so far. * If marks for known samples are distinct, then output marks for unknown * samples indicate which known sample is closest. In this way output * marks can represent a sampled Voronoi diagram, albeit one that has * been generalized by replacing distance with time. *

* This transform uses an iterative sweeping method to solve for times. * Iterations are similar to those described by Jeong and Whitaker (2007). * Computational complexity is O(M log K), where M is the number of * unknown (missing) samples and K is the number of known samples. * @author Dave Hale, Colorado School of Mines * @version 2009.07.21 */ class TimeMarker3X { /** * Type of concurrency used by this transform. */ public enum Concurrency { PARALLEL, SERIAL } /** * Constructs a time marker for the specified tensor field. * @param n1 number of samples in 1st dimension. * @param n2 number of samples in 2nd dimension. * @param n3 number of samples in 2nd dimension. * @param tensors velocity-squared tensors. */ public TimeMarker3X(int n1, int n2, int n3, Tensors3 tensors) { init(n1,n2,n3,tensors); } /** * Sets the tensors used by this time marker. * @param tensors the tensors. */ public void setTensors(Tensors3 tensors) { _tensors = tensors; } /** * Sets the type of concurrency used to solve for times. * The default concurrency is parallel. * @param concurrency the type of concurrency. */ public void setConcurrency(Concurrency concurrency) { _concurrency = concurrency; } /** * Transforms the specified array of times and marks. * Known samples are those for which times are zero, and times * and marks for these known samples are used to compute times * and marks for unknown samples. * @param times input/output array of times. * @param marks input/output array of marks. */ public void apply(float[][][] times, int[][][] marks) { // Measure elapsed time in seconds. Stopwatch sw = new Stopwatch(); sw.start(); log.fine("TimeMarker3X.apply: begin time="+(int)sw.time()); // Make a heap of the known samples. TimeHeap3 theap = makeTimeHeap(times,marks); int nk = theap.size(); log.fine("TimeMarker3X.apply: heap time="+(int)sw.time()); // Initialize all times to infinity. for (int i3=0; i3<_n3; ++i3) { for (int i2=0; i2<_n2; ++i2) { for (int i1=0; i1<_n1; ++i1) { times[i3][i2][i1] = INFINITY; } } } // Array for the eikonal solution times. float[][][] t = new float[_n3][_n2][_n1]; // Active list of samples used to compute times. ActiveList al = new ActiveList(); // For all known samples, ... for (int ik=0; ik© 2015 - 2025 Weber Informatics LLC | Privacy Policy