Beispiel #1
0
void Options::setOptions() {

    PetscInt int_buffer;
    PetscBool parameter_set;
    char char_buffer[PETSC_MAX_PATH_LEN];

    PetscOptionsGetString(NULL, "--exodus_file_name", char_buffer, PETSC_MAX_PATH_LEN,
                          &parameter_set);
    if (parameter_set) { mExodusMeshFile = std::string(char_buffer); }

    PetscOptionsGetString(NULL, "--exodus_model_file_name", char_buffer, PETSC_MAX_PATH_LEN,
                          &parameter_set);
    if (parameter_set) { mExodusModelFile = std::string(char_buffer); }

    PetscOptionsGetString(NULL, "--mesh_type", char_buffer, PETSC_MAX_PATH_LEN,
                          &parameter_set);
    if (parameter_set) { mMeshType = std::string(char_buffer); }

    PetscOptionsGetString(NULL, "--element_shape", char_buffer, PETSC_MAX_PATH_LEN,
                          &parameter_set);
    if (parameter_set) { mElementShape = std::string(char_buffer); }

    PetscOptionsGetString(NULL, "--physics_system", char_buffer, PETSC_MAX_PATH_LEN,
                          &parameter_set);
    if (parameter_set) { mPhysicsSystem = std::string(char_buffer); }

    PetscOptionsGetString(NULL, "--source_type", char_buffer, PETSC_MAX_PATH_LEN,
                          &parameter_set);
    if (parameter_set) { mSourceType = std::string(char_buffer); }

    PetscOptionsGetInt(NULL, "--polynomial_order", &int_buffer, &parameter_set);
    if (parameter_set) { mPolynomialOrder = int_buffer; }

    // Sources.

    PetscOptionsGetInt(NULL, "--number_of_sources", &int_buffer, &parameter_set);
    if (parameter_set) { mNumberSources = int_buffer; }

    mSourceLocationX.resize(mNumberSources);
    mSourceLocationY.resize(mNumberSources);
    mSourceLocationZ.resize(mNumberSources);
    mSourceRickerTimeDelay.resize(mNumberSources);
    mSourceRickerAmplitude.resize(mNumberSources);
    mSourceRickerCenterFreq.resize(mNumberSources);

    PetscOptionsGetScalarArray(NULL, "--source_location_x", mSourceLocationX.data(), &mNumberSources, NULL);
//    PetscOptionsGetScalarArray(NULL, "--source_location_y", mSourceLocationY.data(), &mNumberSources, NULL);
    PetscOptionsGetScalarArray(NULL, "--source_location_z", mSourceLocationZ.data(), &mNumberSources, NULL);
    PetscOptionsGetScalarArray(NULL, "--ricker_amplitude", mSourceRickerAmplitude.data(), &mNumberSources, NULL);
    PetscOptionsGetScalarArray(NULL, "--ricker_time_delay", mSourceRickerTimeDelay.data(), &mNumberSources, NULL);
    PetscOptionsGetScalarArray(NULL, "--ricker_center_freq", mSourceRickerCenterFreq.data(), &mNumberSources, NULL);

}
Beispiel #2
0
std::vector<receiverStruct>
receiver::getReceiversFromOptions()
{
	// get number of receivers
	PetscInt numReceivers;
	PetscOptionsGetInt(NULL, "--number_of_receivers", &numReceivers, NULL);

	// get base directory for where to write receivers
	char dumC[PETSC_MAX_PATH_LEN];
	PetscOptionsGetString(NULL, "--base_write_directory", 
					   	  dumC,
					   	  PETSC_MAX_PATH_LEN, NULL);
	std::string baseName = dumC;
	PetscOptionsGetString(NULL, "--iteration_name",
						  dumC, PETSC_MAX_PATH_LEN, NULL);
	baseName += "/" + std::string(dumC) + "/receivers";

	// make the base dir
	if (MPI::COMM_WORLD.Get_rank() == 0)
	{
		mkdir(baseName.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
	}

	// get receiver parameters
	char *names[numReceivers]; PetscBool dumB = PETSC_FALSE;
	std::vector<PetscScalar> xs(numReceivers);
	std::vector<PetscScalar> ys(numReceivers);
	PetscOptionsGetStringArray(NULL, "--receiver_names", names, &numReceivers, NULL);
	PetscOptionsGetScalarArray(NULL, "--receiver_x", xs.data(), &numReceivers, NULL);
	PetscOptionsGetScalarArray(NULL, "--receiver_y", ys.data(), &numReceivers, NULL);
	PetscOptionsGetBool(NULL, "--write_receivers", &dumB, NULL);

	// add to structures
	std::vector<receiverStruct> receivers;
	for (auto i=0; i<numReceivers; i++)
	{
		receiverStruct r;
		r.name = baseName + "/" + names[i] + ".txt";
		r.xLoc = xs[i];
		r.yLoc = ys[i];
		r.write = dumB;
		receivers.push_back(r);
	}
	return receivers;
}
Beispiel #3
0
/* Sets the initial solution for the IVP and sets up the function pointers*/
PetscErrorCode Initialize(Vec Y, void* s)
{
  PetscErrorCode ierr;
  char          *p = (char*) s;
  PetscScalar   *y;
  PetscInt      N = GetSize((const char *)s);
  PetscBool     flg;

  PetscFunctionBegin;
  VecZeroEntries(Y);
  ierr = VecGetArray(Y,&y);CHKERRQ(ierr);
  if (!strcmp(p,"hull1972a1")) {
    y[0] = 1.0;
    RHSFunction = RHSFunction_Hull1972A1;
    IFunction   = IFunction_Hull1972A1;
    IJacobian   = IJacobian_Hull1972A1;
  } else if (!strcmp(p,"hull1972a2")) {
    y[0] = 1.0;
    RHSFunction = RHSFunction_Hull1972A2;
    IFunction   = IFunction_Hull1972A2;
    IJacobian   = IJacobian_Hull1972A2;
  } else if (!strcmp(p,"hull1972a3")) {
    y[0] = 1.0;
    RHSFunction = RHSFunction_Hull1972A3;
    IFunction   = IFunction_Hull1972A3;
    IJacobian   = IJacobian_Hull1972A3;
  } else if (!strcmp(p,"hull1972a4")) {
    y[0] = 1.0;
    RHSFunction = RHSFunction_Hull1972A4;
    IFunction   = IFunction_Hull1972A4;
    IJacobian   = IJacobian_Hull1972A4;
  } else if (!strcmp(p,"hull1972a5")) {
    y[0] = 4.0;
    RHSFunction = RHSFunction_Hull1972A5;
    IFunction   = IFunction_Hull1972A5;
    IJacobian   = IJacobian_Hull1972A5;
  } else if (!strcmp(p,"hull1972b1")) {
    y[0] = 1.0;
    y[1] = 3.0;
    RHSFunction = RHSFunction_Hull1972B1;
    IFunction   = IFunction_Hull1972B1;
    IJacobian   = IJacobian_Hull1972B1;
  } else if (!strcmp(p,"hull1972b2")) {
    y[0] = 2.0;
    y[1] = 0.0;
    y[2] = 1.0;
    RHSFunction = RHSFunction_Hull1972B2;
    IFunction   = IFunction_Hull1972B2;
    IJacobian   = IJacobian_Hull1972B2;
  } else if (!strcmp(p,"hull1972b3")) {
    y[0] = 1.0;
    y[1] = 0.0;
    y[2] = 0.0;
    RHSFunction = RHSFunction_Hull1972B3;
    IFunction   = IFunction_Hull1972B3;
    IJacobian   = IJacobian_Hull1972B3;
  } else if (!strcmp(p,"hull1972b4")) {
    y[0] = 3.0;
    y[1] = 0.0;
    y[2] = 0.0;
    RHSFunction = RHSFunction_Hull1972B4;
    IFunction   = IFunction_Hull1972B4;
    IJacobian   = IJacobian_Hull1972B4;
  } else if (!strcmp(p,"hull1972b5")) {
    y[0] = 0.0;
    y[1] = 1.0;
    y[2] = 1.0;
    RHSFunction = RHSFunction_Hull1972B5;
    IFunction   = IFunction_Hull1972B5;
    IJacobian   = IJacobian_Hull1972B5;
  } else if (!strcmp(p,"hull1972c1")) {
    y[0] = 1.0;
    RHSFunction = RHSFunction_Hull1972C1;
    IFunction   = IFunction_Hull1972C1;
    IJacobian   = IJacobian_Hull1972C1;
  } else if (!strcmp(p,"hull1972c2")) {
    y[0] = 1.0;
    RHSFunction = RHSFunction_Hull1972C2;
    IFunction   = IFunction_Hull1972C2;
    IJacobian   = IJacobian_Hull1972C2;
  } else if ((!strcmp(p,"hull1972c3"))
           ||(!strcmp(p,"hull1972c4"))){
    y[0] = 1.0;
    RHSFunction = RHSFunction_Hull1972C34;
    IFunction   = IFunction_Hull1972C34;
    IJacobian   = IJacobian_Hull1972C34;
  }
  ierr = PetscOptionsGetScalarArray(NULL,"-yinit",y,&N,&flg);CHKERRQ(ierr);
  if ((N != GetSize((const char*)s)) && flg) {
    SETERRQ2(PETSC_COMM_WORLD,PETSC_ERR_ARG_SIZ,"Number of initial values %D does not match problem size %D.\n",N,GetSize((const char*)s));
  }
  ierr = VecRestoreArray(Y,&y);CHKERRQ(ierr);
  PetscFunctionReturn(0);
}