From 440fd67571378027bd607ef5e47f25e455d418bd Mon Sep 17 00:00:00 2001 From: Robert Walker Date: Wed, 25 Oct 2023 14:20:37 -0700 Subject: [PATCH] Passes libtest for source --- .../AuxiliaryFactoryMomentTensorForce.cc | 2 +- .../sources/AuxiliaryFactorySourceTime.cc | 3 ++- .../TestAuxiliaryFactoryMomentTensorForce.cc | 4 ++-- ...AuxiliaryFactoryMomentTensorForce_Cases.cc | 24 +++++++++---------- .../sources/TestAuxiliaryFactorySourceTime.cc | 6 ++--- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/libsrc/pylith/sources/AuxiliaryFactoryMomentTensorForce.cc b/libsrc/pylith/sources/AuxiliaryFactoryMomentTensorForce.cc index 188d896253..8a986dc2a4 100644 --- a/libsrc/pylith/sources/AuxiliaryFactoryMomentTensorForce.cc +++ b/libsrc/pylith/sources/AuxiliaryFactoryMomentTensorForce.cc @@ -64,7 +64,7 @@ pylith::sources::AuxiliaryFactoryMomentTensorForce::addMomentTensor(void) { // m pylith::topology::Field::Description description; description.label = subfieldName; description.alias = subfieldName; - description.vectorFieldType = pylith::topology::Field::OTHER; + description.vectorFieldType = (3 == _spaceDim) ? pylith::topology::Field::TENSOR : pylith::topology::Field::OTHER; description.numComponents = tensorSize; description.componentNames.resize(tensorSize); for (int i = 0; i < tensorSize; ++i) { diff --git a/libsrc/pylith/sources/AuxiliaryFactorySourceTime.cc b/libsrc/pylith/sources/AuxiliaryFactorySourceTime.cc index 9bd2ce3fd5..39b040f9db 100644 --- a/libsrc/pylith/sources/AuxiliaryFactorySourceTime.cc +++ b/libsrc/pylith/sources/AuxiliaryFactorySourceTime.cc @@ -50,6 +50,7 @@ pylith::sources::AuxiliaryFactorySourceTime::addCenterFrequency(void) { // cente PYLITH_JOURNAL_DEBUG("addCenterFrequency(void)"); const char* subfieldName = "center_frequency"; + const PylithReal timeScale = _normalizer->getTimeScale(); pylith::topology::Field::Description description; description.label = subfieldName; @@ -58,7 +59,7 @@ pylith::sources::AuxiliaryFactorySourceTime::addCenterFrequency(void) { // cente description.numComponents = 1; description.componentNames.resize(1); description.componentNames[0] = subfieldName; - description.scale = 1.0; + description.scale = 1.0 / timeScale; description.validator = pylith::topology::FieldQuery::validatorNonnegative; _field->subfieldAdd(description, getSubfieldDiscretization(subfieldName)); diff --git a/tests/libtests/sources/TestAuxiliaryFactoryMomentTensorForce.cc b/tests/libtests/sources/TestAuxiliaryFactoryMomentTensorForce.cc index 7267e22ddc..bda73860f4 100644 --- a/tests/libtests/sources/TestAuxiliaryFactoryMomentTensorForce.cc +++ b/tests/libtests/sources/TestAuxiliaryFactoryMomentTensorForce.cc @@ -72,7 +72,7 @@ pylith::sources::TestAuxiliaryFactoryMomentTensorForce::TestAuxiliaryFactoryMome info.fe = pylith::topology::Field::Discretization( 2, 2, _data->auxDim, _data->auxDim, false, pylith::topology::Field::DEFAULT_BASIS, pylith::topology::Field::POLYNOMIAL_SPACE, false ); - info.index = 3; + info.index = 0; _data->subfields["moment_tensor"] = info; if (2 == _data->auxDim) { _data->subfields["moment_tensor"].description.numComponents = 4; @@ -94,7 +94,7 @@ pylith::sources::TestAuxiliaryFactoryMomentTensorForce::TestAuxiliaryFactoryMome info.fe = pylith::topology::Field::Discretization( 1, 2, _data->auxDim, 1, false, pylith::topology::Field::DEFAULT_BASIS, pylith::topology::Field::POLYNOMIAL_SPACE, true ); - info.index = 0; + info.index = 1; _data->subfields["time_delay"] = info; _initialize(); diff --git a/tests/libtests/sources/TestAuxiliaryFactoryMomentTensorForce_Cases.cc b/tests/libtests/sources/TestAuxiliaryFactoryMomentTensorForce_Cases.cc index 6b59c2f6e2..aa0de17b7a 100644 --- a/tests/libtests/sources/TestAuxiliaryFactoryMomentTensorForce_Cases.cc +++ b/tests/libtests/sources/TestAuxiliaryFactoryMomentTensorForce_Cases.cc @@ -72,9 +72,9 @@ class pylith::sources::TestAuxiliaryFactoryMomentTensorForce_Cases { } static - const char* pressure_units(void) { + const char* moment_tensor_units(void) { return "Pa"; - } // pressure_units + } // moment_tensor_units static double time_delay_2d(const double x, @@ -166,10 +166,10 @@ pylith::sources::TestAuxiliaryFactoryMomentTensorForce_Cases::Tri(void) { data->cs->setSpaceDim(data->dimension); assert(data->auxiliaryDB); - data->auxiliaryDB->addValue("moment_tensor_xx", moment_tensor_2d_xx, pressure_units()); - data->auxiliaryDB->addValue("moment_tensor_yy", moment_tensor_2d_yy, pressure_units()); - data->auxiliaryDB->addValue("moment_tensor_zz", moment_tensor_2d_zz, pressure_units()); - data->auxiliaryDB->addValue("moment_tensor_xy", moment_tensor_2d_xy, pressure_units()); + data->auxiliaryDB->addValue("moment_tensor_xx", moment_tensor_2d_xx, moment_tensor_units()); + data->auxiliaryDB->addValue("moment_tensor_yy", moment_tensor_2d_yy, moment_tensor_units()); + data->auxiliaryDB->addValue("moment_tensor_zz", moment_tensor_2d_zz, moment_tensor_units()); + data->auxiliaryDB->addValue("moment_tensor_xy", moment_tensor_2d_xy, moment_tensor_units()); data->auxiliaryDB->addValue("time_delay", time_delay_2d, time_units()); data->auxiliaryDB->setDescription("auxiliary"); data->auxiliaryDB->setCoordSys(*data->cs); @@ -191,12 +191,12 @@ pylith::sources::TestAuxiliaryFactoryMomentTensorForce_Cases::Hex(void) { data->cs->setSpaceDim(data->dimension); assert(data->auxiliaryDB); - data->auxiliaryDB->addValue("moment_tensor_xx", moment_tensor_3d_xx, pressure_units()); - data->auxiliaryDB->addValue("moment_tensor_yy", moment_tensor_3d_yy, pressure_units()); - data->auxiliaryDB->addValue("moment_tensor_zz", moment_tensor_3d_zz, pressure_units()); - data->auxiliaryDB->addValue("moment_tensor_xy", moment_tensor_3d_xy, pressure_units()); - data->auxiliaryDB->addValue("moment_tensor_yz", moment_tensor_3d_yz, pressure_units()); - data->auxiliaryDB->addValue("moment_tensor_xz", moment_tensor_3d_xz, pressure_units()); + data->auxiliaryDB->addValue("moment_tensor_xx", moment_tensor_3d_xx, moment_tensor_units()); + data->auxiliaryDB->addValue("moment_tensor_yy", moment_tensor_3d_yy, moment_tensor_units()); + data->auxiliaryDB->addValue("moment_tensor_zz", moment_tensor_3d_zz, moment_tensor_units()); + data->auxiliaryDB->addValue("moment_tensor_xy", moment_tensor_3d_xy, moment_tensor_units()); + data->auxiliaryDB->addValue("moment_tensor_yz", moment_tensor_3d_yz, moment_tensor_units()); + data->auxiliaryDB->addValue("moment_tensor_xz", moment_tensor_3d_xz, moment_tensor_units()); data->auxiliaryDB->addValue("time_delay", time_delay_3d, time_units()); data->auxiliaryDB->setDescription("auxiliary"); data->auxiliaryDB->setCoordSys(*data->cs); diff --git a/tests/libtests/sources/TestAuxiliaryFactorySourceTime.cc b/tests/libtests/sources/TestAuxiliaryFactorySourceTime.cc index 03f57ea246..b45fb3ee43 100644 --- a/tests/libtests/sources/TestAuxiliaryFactorySourceTime.cc +++ b/tests/libtests/sources/TestAuxiliaryFactorySourceTime.cc @@ -73,7 +73,7 @@ pylith::sources::TestAuxiliaryFactorySourceTime::TestAuxiliaryFactorySourceTime( info.fe = pylith::topology::Field::Discretization( 2, 2, _data->auxDim, _data->auxDim, false, pylith::topology::Field::DEFAULT_BASIS, pylith::topology::Field::POLYNOMIAL_SPACE, false ); - info.index = 3; + info.index = 0; _data->subfields["moment_tensor"] = info; if (2 == _data->auxDim) { _data->subfields["moment_tensor"].description.numComponents = 4; @@ -95,7 +95,7 @@ pylith::sources::TestAuxiliaryFactorySourceTime::TestAuxiliaryFactorySourceTime( info.fe = pylith::topology::Field::Discretization( 1, 2, _data->auxDim, 1, false, pylith::topology::Field::DEFAULT_BASIS, pylith::topology::Field::POLYNOMIAL_SPACE, true ); - info.index = 0; + info.index = 1; _data->subfields["time_delay"] = info; // centerFrequency @@ -113,7 +113,7 @@ pylith::sources::TestAuxiliaryFactorySourceTime::TestAuxiliaryFactorySourceTime( info.fe = pylith::topology::Field::Discretization( 2, 2, _data->auxDim, 1, false, pylith::topology::Field::DEFAULT_BASIS, pylith::topology::Field::POLYNOMIAL_SPACE, true ); - info.index = 0; + info.index = 2; _data->subfields["center_frequency"] = info; _initialize();