Example #1
0
    def _setup(self):
        options = self.options
        nx = self.training_points[None][0][0].shape[1]

        for name in ['smoothness', 'num_elements']:
            if isinstance(options[name], (int, float)):
                options[name] = [options[name]] * nx
            options[name] = np.atleast_1d(options[name])

        self.printer.max_print_depth = options['max_print_depth']

        num = {}
        # number of inputs and outputs
        num['x'] = self.training_points[None][0][0].shape[1]
        num['y'] = self.training_points[None][0][1].shape[1]
        # number of elements
        num['elem_list'] = np.array(options['num_elements'], int)
        num['elem'] = np.prod(num['elem_list'])
        # number of terms/coefficients per element
        num['term_list'] = 4 * np.ones(num['x'], int)
        num['term'] = np.prod(num['term_list'])
        # number of nodes
        num['uniq_list'] = num['elem_list'] + 1
        num['uniq'] = np.prod(num['uniq_list'])
        # total number of training points (function values and derivatives)
        num['t'] = 0
        for kx in self.training_points[None]:
            num['t'] += self.training_points[None][kx][0].shape[0]
        # for RMT
        num['coeff'] = num['term'] * num['elem']
        num['support'] = num['term']
        num['dof'] = num['uniq'] * 2**num['x']

        self.num = num

        self.rmtsc = PyRMTC()
        self.rmtsc.setup(
            num['x'],
            np.array(self.options['xlimits'][:, 0]),
            np.array(self.options['xlimits'][:, 1]),
            np.array(num['elem_list'], np.int32),
            np.array(num['term_list'], np.int32),
        )
Example #2
0
    def _setup(self):
        options = self.options
        nx = self.training_points[None][0][0].shape[1]

        for name in ["smoothness", "num_elements"]:
            if isinstance(options[name], (int, float)):
                options[name] = [options[name]] * nx
            options[name] = np.atleast_1d(options[name])

        self.printer.max_print_depth = options["max_print_depth"]

        num = {}
        # number of inputs and outputs
        num["x"] = self.training_points[None][0][0].shape[1]
        num["y"] = self.training_points[None][0][1].shape[1]
        # number of elements
        num["elem_list"] = np.array(options["num_elements"], int)
        num["elem"] = np.prod(num["elem_list"])
        # number of terms/coefficients per element
        num["term_list"] = 4 * np.ones(num["x"], int)
        num["term"] = np.prod(num["term_list"])
        # number of nodes
        num["uniq_list"] = num["elem_list"] + 1
        num["uniq"] = np.prod(num["uniq_list"])
        # total number of training points (function values and derivatives)
        num["t"] = 0
        for kx in self.training_points[None]:
            num["t"] += self.training_points[None][kx][0].shape[0]
        # for RMT
        num["coeff"] = num["term"] * num["elem"]
        num["support"] = num["term"]
        num["dof"] = num["uniq"] * 2**num["x"]

        self.num = num

        self.rmtsc = PyRMTC()
        self.rmtsc.setup(
            num["x"],
            np.array(self.options["xlimits"][:, 0]),
            np.array(self.options["xlimits"][:, 1]),
            np.array(num["elem_list"], np.int32),
            np.array(num["term_list"], np.int32),
        )